Click to See Complete Forum and Search --> : GDI+ Problem


int v = 44
December 30th, 2005, 04:15 PM
I'm making a program where the user draws points on an image. Currently it draws on the form background. But with that I can't save the image. When I tried to draw on a Picture Box, It kept giving me errors such as object not set at a point or something when using the MouseDown MouseUp functions.

My question is: How can I best allow the user to draw a line from one point to the next and be able to save the image and not loose it to the PaintEventArgs. Thanks.

bilm_ks
January 2nd, 2006, 03:34 PM
You are talking for .NET. If yes use Bitmap class as buffer and create a graphics object from this (FromImage mthd). Draw your lines into image and then display the image with the graphics of your form (DrawImage mthd). You have the same picture both in Bitmap and screen.

cindyonlyone
January 2nd, 2006, 08:22 PM
Image* image = new Image (L"test_emf333.tmp", TRUE);

#ifdef _UNICODE
CString lpwstr = strFileName;
#else if
LPWSTR lpwstr = A2W(strFileName);
#endif

CLSID encoderClsid;
Status stat;
// Get the CLSID of the BMP encoder.
if (GetEncoderClsid(L"image/bmp", &encoderClsid) != -1)
stat = image->Save(lpwstr, &encoderClsid, NULL);

You can also drawing your line to EMF Plus Device,and then convert the drawing to bitmap,see above codes.

Cindy
--------------------------------------------------------------------------
For high quality flow/diagram MFC/C++ Visio Like visualization Source Code,download XD++ at: http://www.********.net