2011-04-20 76 views
1

您好目前我使用C#,我有一個圖像的像素數據,我想要轉換爲Jpg/png格式?你可以建議我任何庫或做.net提供任何壓縮API?將像素數據壓縮爲jpg/png格式

+0

可能重複的[骨形態發生蛋白,以JPG/PNG在C#(http://stackoverflow.com/questions/41665/bmp-to-jpg-png-in-c) – Oliver 2011-04-20 12:14:13

回答

0

嘗試這種情況:

 //example 1: converting from bitmap 
     Bitmap myImage1 = new Bitmap(@"C:\myimage1.bmp"); 

     myImage1.Save(@"C:\myimage1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); 
     myImage1.Save(@"C:\myimage1.png", System.Drawing.Imaging.ImageFormat.Png); 


     //example 2: converting from pixels 
     Bitmap myImage2 = new Bitmap(10, 10); 

     //for loop to set some pixels 
     for (int x=0;x<10;x++) 
      for (int y=0;y<10;y++) 
       myImage2.SetPixel(x,y,Color.Blue); 

     myImage2.Save(@"C:\myimage2.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); 
     myImage2.Save(@"C:\myimage2.png", System.Drawing.Imaging.ImageFormat.Png);