views:

281

answers:

1

Hello , this is code which i use to make image.

Bitmap bitmap;
bitmap.CreateBitmap(715, 844,1,1, NULL);

CDC memDC;
memDC.CreateCompatibleDC(NULL);
memDC.SelectObject(&bitmap);

CString SS="Sun Goes Down";
 memDC.TextOutA(1,2,SS);

        CImage image;
        image.Attach(bitmap);
        image.Save(_T("C:\\test.bmp"), Gdiplus::ImageFormatJPEG);

and all is ok , now all i want is to send that image to print...

i use

    DWORD pcchBuffer=100;

  char * pszBuffer=new char[100];

 GetDefaultPrinter(pszBuffer,&pcchBuffer);

again all is ok.

to get defaulet printername , for print i know WritePrinter function, but that fonction gives argumens LPVOID buffer to print , how can i send my image to print? Many many Thanks!

+2  A: 

Instead of making the image, saving it, then printing it, you should:

Look for all the detailed steps on MSDN.

Patrick
ok , thanks! that's right, but problem is - i want and image and print , is possble to create new CDC for print as described and do all DRAWING as it do for image ? (DRAWING is large code , and i do not want to do it and for print and for image) . please if you can , help me!
Armen Khachatryan
You could first perform all the complex image drawing into a DC of a bitmap (as in your question), then save it, open a DC for the printer, and draw the bitmap in the DC of the printer. That way, you will only have to do the complex drawing once.
Patrick