Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将像素数据压缩为jpg/png格式_C#_Compression_Png_Jpeg - Fatal编程技术网

C# 将像素数据压缩为jpg/png格式

C# 将像素数据压缩为jpg/png格式,c#,compression,png,jpeg,C#,Compression,Png,Jpeg,您好,目前我正在使用C#,我有一个图像的像素数据,我想转换成Jpg/png格式?您能给我推荐一些库吗?或者.net是否提供任何压缩API?试试以下方法: //example 1: converting from bitmap Bitmap myImage1 = new Bitmap(@"C:\myimage1.bmp"); myImage1.Save(@"C:\myimage1.jpg", System.Drawing.Imaging.Image

您好,目前我正在使用C#,我有一个图像的像素数据,我想转换成Jpg/png格式?您能给我推荐一些库吗?或者.net是否提供任何压缩API?

试试以下方法:

        //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);
//示例1:从位图转换
位图myImage1=新位图(@“C:\myImage1.bmp”);
myImage1.Save(@“C:\myImage1.jpg”,System.Drawing.Imaging.ImageFormat.Jpeg);
保存(@“C:\myImage1.png”,System.Drawing.Imaging.ImageFormat.png);
//示例2:从像素转换
位图myImage2=新位图(10,10);
//为循环设置一些像素
对于(int x=0;x的可能重复项)