1

Hi currently i am using C#, I have pixel data of an image which i want to convert to Jpg/png format? Can you suggest me any libraries or does .net provide any compression API?

mohan
  • 1,340
  • 3
  • 15
  • 27
  • possible duplicate of [Bmp to jpg/png in C#](http://stackoverflow.com/questions/41665/bmp-to-jpg-png-in-c) – Oliver Apr 20 '11 at 12:14

1 Answers1

0

Try this:

        //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);
Jason Moore
  • 3,294
  • 15
  • 18