  | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ลองแล้วครับ 
ไม่ได้ 
 
อยากได้แบบ Draw Img มากกว่าครับ 
 
อีกอย่างเวลา Save ผ่าน Dataset                        
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2010-07-09 21:20:33 | 
                        By :
                            evekrub | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Code (C#) 
BinaryReader BinaryRead = new BinaryReader(FileUpload1.PostedFile.InputStream); 
byte[] BinaryData = BinaryRead.ReadBytes(FileUpload1.PostedFile.ContentLength); 
  
 
 
ถ้าเปลี่ยนเป็น PictureBox ต้องเปลี่ยนตรงไหนบ้างครับ                        
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2010-07-09 21:27:37 | 
                        By :
                            evekrub | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 เซ็งนะเนี่ย เวลาเขียนโค้ดให้แล้วไม่มีคนเข้าใจน่ะ 
 
กลับไปดู no.1 ดีๆ มีมากกว่าที่คุณต้องการ                        
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2010-07-09 21:34:26 | 
                        By :
                            tungman | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ดู Code มาแล้วครับ 
 
แต่ว่าติด Code (C#) 
byte[] imageBytes = (byte[])Dt.Rows[0]["BinaryData"];
  
 
ติดตรง Dt  เพราะว่าผมใช้การ insert ข้อมูล แบบ Dataset  
 
ต้องแก้ไขอย่างไรครับ                        
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2010-07-09 21:36:21 | 
                        By :
                            evekrub | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ตอนนี้สามารถบันทึกลงใน ฐานข้อมูลเรียบร้อยแล้ว  
 
แต่ว่าถ้าต้องการกำหนดขนาดของรูปภาพก่อนลงฐานข้อมูล  ต้องใช้คำสั่งอะไรครับ                        
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2010-07-11 21:09:06 | 
                        By :
                            evekrub | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ผมว่าที่ผมให้ไปมันมีหมดนะ 
 
Code (C#) 
        private  void DisplayImage(string ImagePath)
        {
            byte[] imageBytes = Security.DecryptStream(ImagePath, SecretKey);
 
            Image myImage  = Image.FromStream(new MemoryStream(imageBytes));
            Size fitImageSize = ScaledImageDimensions(myImage.Width, myImage.Height, PictureBox1.Width, PictureBox1.Height);
            Bitmap imgOutput = new Bitmap(myImage, fitImageSize.Width, fitImageSize.Height);
 
            PictureBox1.Image = null;
            PictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
            PictureBox1.Image = imgOutput;
        }
        private Size ScaledImageDimensions(int currentImageWidth, int currentImageHeight, int desiredImageWidth, int desiredImageHeight)
        {
            /* First, we must calculate a multiplier that will be used
             * to get the dimensions of the new, scaled image. */
            double scaleImageMultiplier = 0;
            /* This multiplier is defined as the ratio of the
             * Desired Dimension to the Current Dimension.
             * Specifically which dimension is used depends on the larger
             * dimension of the image, as this will be the constraining dimension
             * when we fit to the window. */
            /* Determine if Image is Portrait or Landscape. */    
            if (currentImageHeight > currentImageWidth) /* Image is Portrait */
            {
                /* Calculate the multiplier based on the heights. */
                if (desiredImageHeight > desiredImageWidth)
                {
                    scaleImageMultiplier = (double)desiredImageWidth / (double)currentImageWidth;
                }
                else
                {
                    scaleImageMultiplier = (double)desiredImageHeight / (double)currentImageHeight;
                }
            }
            else /* Image is Landscape */
            {
                /* Calculate the multiplier based on the widths. */
                if (desiredImageWidth > desiredImageHeight)
                {
                    scaleImageMultiplier = (double)desiredImageWidth / (double)currentImageWidth;
                }
                else
                {
                    scaleImageMultiplier = (double)desiredImageHeight / (double)currentImageHeight;
                }
            }
            /* Generate and return the new scaled dimensions.
             * Essentially, we multiply each dimension of the original image
             * by the multiplier calculated above to yield the dimensions
             * of the scaled image. The scaled image can be larger or smaller
             * than the original. */
            int outputWidth = (int)(currentImageWidth * scaleImageMultiplier);
            int outputHight = (int)(currentImageHeight * scaleImageMultiplier);
            return new Size((currentImageWidth > outputWidth) ? outputWidth : currentImageWidth, (currentImageHeight > outputHight) ? outputHight : currentImageHeight);
        }
 
 
เอา bitmap ที่ resize แล้ว แปลงเป็น byte[] อีกที แล้วก็เอาไปเก็บ                        
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2010-07-11 21:41:47 | 
                        By :
                            tungman | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     |