嗨,目前我正在使用C#,我有一个想要转换为Jpg / png格式的图像的像素数据?你能建议我使用任何库吗?或.net提供任何压缩API吗?
答案 0 :(得分: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);