Advertisement

03.01.2008 at 07:13PM PST, ID: 23206994
[x]
Attachment Details

Saving A Bitmap object to a JPEG File

Asked by hoyaabanks in .Net Editors & IDEs, Microsoft Visual C#.Net, .NET Framework 2.0

Tags: Microsoft, Visual Studio.NET, 2005, ASP.NET C#

How do you go about saving a bitmap object to a jpeg file.  I have a web service that communicates with a flash app.  THe flash app sends this giant pixle string with hex value for each pixle color.  All one string.  I take that and translate it into a Bitmap.  Now how do I save a jpeg file from the Bitmap?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
[WebMethod]
    public void SendEasterEgg(string pixelData)
    {
        int width = 374;
        int height = 354;
        Bitmap bmp = null;   
  
        string curPixelColor = String.Empty;   
  
        int x = 0;   
        int y = 0;
 
        if (pixelData != String.Empty)   
        {   
            // Here we create a Bitmap object that has the same size as the one in Flash   
            bmp = new Bitmap(width, height);   
  
            // Iterate through each group of six characters and convert them to a Color   
            // then assign that color to the pixel of the Bitmap object   
            for (int i = 0; i < pixelData.Length / 6; i++)   
            {   
                curPixelColor = pixelData.Substring(i * 6, 6);   
                bmp.SetPixel(x,y, ColorTranslator.FromHtml("0x" + curPixelColor));   
  
                if(x==width-1)   
                {   
                    x = 0;   
                    y++;   
                }   
                else  
                {   
                    x++;   
                }   
            }   
 
            //
            // TODO: Save Bitmap File to Jpeg
            //
        }
 
 
Loading Advertisement...
 
[+][-]03.01.2008 at 07:28PM PST, ID: 21024798

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.01.2008 at 07:52PM PST, ID: 21024853

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.01.2008 at 09:01PM PST, ID: 21025031

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .Net Editors & IDEs, Microsoft Visual C#.Net, .NET Framework 2.0
Tags: Microsoft, Visual Studio.NET, 2005, ASP.NET C#
Sign Up Now!
Solution Provided By: ee_rlee
Participating Experts: 2
Solution Grade: A
 
 
[+][-]03.02.2008 at 05:53AM PST, ID: 21025982

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 07:43PM PDT, ID: 21674883

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 05:53PM PDT, ID: 21705811

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628