Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

printing floodfill bitmap to a printer

9 views
Skip to first unread message

Lynn McGuire

unread,
Sep 4, 2013, 6:16:24 PM9/4/13
to
Hi,

I have an issue with a fix I made to allow a flood
filled object be printed.

We were using the windows GDI FloodFill function,
which we noticed doesnt work on printers. What I
found on the internet, was to create a memory DC,
compatible with the printer DC, and make all my
drawing operations on the memory DC, and then
BitBlt it all at once to the printer DC (I had to
change to use a recursive, color replacement flood
fill function too, since the memory DC only allows
what the main DC did).

The problem is the memory DC seems to be a pixel
or two bigger on the x and y, but I dont know what
to do, when i get the selected bitmap from the
memory DC, it shows it to be the correct size, I
would like to use StretchBlt, but the values I
have access to use as params for StretchBlt, make
it no different than calling BitBlt.

Please let me know if you need more info.

Sincerely,
Lynn McGuire

heres my code:

HDC hMemPrnDC = CreateCompatibleDC (hPrnDC);
HBITMAP hBitmap = CreateCompatibleBitmap (hPrnDC, iWidthLP, iHeightLP);
HBITMAP hOldBitmap = SelectBitmap (hMemPrnDC, hBitmap);

// paint the whole memory DC with the window color
HBRUSH hBrush = CreateSolidBrush (GetSysColor (COLOR_WINDOW));
RECT rect;
// add one to right and bottom, FillRect doesnt include the right and bottom edges
SetRect (&rect, 0, 0, iWidthLP + 1, iHeightLP + 1);
// NOTE: im doing this cause it starts out as all black
FillRect (hMemPrnDC, &rect, hBrush);

// delete object
DeleteBrush (hBrush);

//
// do all my MoveToEx, LineTo, Ellipse, Arc, TextOut,
// SetPixel, etc calls on hMemPrnDC here
//

// copy all the memory DC drawing data to the printer DC
BitBlt (hPrnDC, 0, 0, iWidthLP, iHeightLP, hMemPrnDC, 0, 0, SRCCOPY);

// select old bitmap, and clean up objects
SelectBitmap (hMemPrnDC, hOldBitmap);
DeleteBitmap (hBitmap);
DeleteDC (hMemPrnDC);
hMemPrnDC = NULL;

0 new messages