Click to See Complete Forum and Search --> : how to save the shapes i draw


mmmddd
December 21st, 2005, 03:00 PM
Hello, i am new to graphics, and need an easy answer
i am drawing shapes to the screen by Graphics class, and need to save the shapes at the screen into bitmap, jpg,gif or any format.
can u pls tell me how can i save the screen with Graphics class, or any method to save thye screen, or the region on the screen

my code is like that;

Graphics __gc * gp=CreatGraphic();
Pen __gc *PenBlack=new Pen(Color::Black,2);
gp->DrawLine(PenBlack,10,10,100,100);
gp->DrawLine(PenBlack,50,50,100,200);
//----------

// here i need to save the shapes at the screen or part of screen

//----------

please give a quick code to achive this

thanks for who deals :)

Mike Harnad
December 21st, 2005, 04:36 PM
Have you looked at the Bitmap section (http://www.codeguru.com/Cpp/G-M/bitmap/) ? There are many articles there that explain how to save a screen image.

cindyonlyone
January 2nd, 2006, 08:39 PM
You can use GDI+ instead,at first you can drawing your shapes on EMF Plus,then:
Image* image = new Image (L"xxx.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);

Then you can convert it to bitmap.

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