Saving image after modification on a pocket pc 2003

Greeings, I want to write a code by which I can modify a picture included in the picturebox by clicking on it and click event puts a red dot on the postion of click. I want to save the image along with the dot I have put on the image. But saving it just saves the real image and no dots get included. Following is the code. I am using CF 2.0.

On event of click of picture box

{

Bitmap bmp = new Bitmap(pictureBox1.Image);

Graphics g = Graphics.FromImage(bmp);

SolitBrush redbrush = new SolidBrush(Color.Red);

Rectangle rect = new Rectangle(mouse_x - 6, mouse_y - 6, 12, 12);

float statangle = 0.0F;

float sweepangle = 360.0F;

g.FillPie(redbrush, rect,startangle, sweepangle);

pictureBox1.Image.Save(C:\\blablabla...");

}

mouse_x and mouse_y are obtained from mousemove event and MouseEventArgs e

x_mouse = e.X;

y_mouse = e.Y;

Any help would be greatly appreciated!!!

Arpit Arora




Answer this question

Saving image after modification on a pocket pc 2003

  • C#2.0

  • StephenWalker

    Grumble, I think the forum web page god ate my last post.

    Unforetunately the NotSupportedException is the correct result. Its not very clear but really support in CF for the various image format depends upon support in the OS. Internally CF doesn't implement any of the various encoding and decoding algorithms (size reasons mostly) so instead we call the native image encoding functions provided by the OS. In the case of WindowsMobile 2003 JPGs can be read but not written by the native APIs which is why we also return NotSupportedException. Sorry for the bad news but hope that clarifies things,

    -Noah

    .Net Compact Framework


  • wabo

    thanks alot noah...i got it.

    Cheers

    Arpit Arora



  • rax

    If you really need to save the image as a JPEG, The Independent JPEG Group (IJG) has a library out there that you can compile into a native dll. Then P/Invoke that from your C# code and you could save that as a JPEG. Now that I think about it, look in the \Windows directory of your device, their should be a jpeg.dll (if you have a pocketpc 2003). I think that is the IJG's JPEG library if you have that already on your device. So if you could figure out what functions it exports (using dumpbin) you could P/Invoke them and save your picture as a JPEG.

  • Remco van Reij

    When you make a new Bitmap you have copied the image that was in the picturebox. Then the graphics object is operating on your copy rather than the on screen image. Saving the original image therefore won't have the dot which was added in the copy. In order to update the image being used by the PictureBox you should add:

    pictureBox1.Image = bmp;

    After that you could use

    pictureBox1.Image.Save() or just bmp.Save() since they now refer to the same updated Bitmap.

    Also I should mention that the above code didn't draw any dot on the screen when I tried it. Since Graphics.FillPie isn't supported on NetCF (you can use FillElipse instead ) I am guessing that the code above isn't exactly what you ran which would explain the discrepancy.

    Hope that works for you,

    -Noah Falk

    .Net Compact Framework


  • Vignesh_dev

    Thanks noah, hope its made fine in the future version of visual studio.

    Arpit.



  • Shawnk

    k, although i got it working on the pocket PC, i cant save the image as a jpg file. Image Format 'Jpeg' is shown supported. Following is the code that works when I save the image as a bitmap file.

    Bitmap bmp = new Bitmap(pictureBox1.Image);

    Graphics g = Graphics.FromImage(bmp);

    SolidBrush redbrush = new SolidBrush(Color.Red);

    Rectangle rect = new Rectangle(mouse_x - 4, mouse_y - 4, 8, 8);

    g.FillEllipse(redbrush, rect);

    pictureBox1.Image = bmp;

    pictureBox1.Refresh();

    bmp.Save("SD Card\\blank.bmp", System.Drawing.Imaging.ImageFormat.Bmp);

    But when I change the last line of the above code to

    bmp.Save("SD Card\\blank.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

    then NotSupportedException was unhandled pops up at debuging even though Image Format of Jpeg is supported in CF 2.0. for mobile 2003.

    Any suggestions..

    Arpit Arora



  • Saving image after modification on a pocket pc 2003