Click to See Complete Forum and Search --> : Bitmaps


Rory
September 26th, 1999, 02:09 PM
I have a CDC and a resource bitmap. Is there any way to put the resource bitmap into the CDC:

eg.CDC aDC;

// aDC is attached to printer here

CBitmap aBitmap;
aBitmap.LoadBitmap(IDB_BITMAP);

// How can I insert the contents of aBitmap into aDC?

Is there way to do it this way, or in any other ways?

Thanks

Rory Condon
Lead Programmer Anarchic Chicken Software
http://www.anarchic-chicken.8m.com

martho
September 26th, 1999, 06:03 PM
.. just try:

CBitmap *oldBmp = aDC.SelectObject(&aBitmap)
... some code, don't forgett to use
aDC.SelectObject(oldBmp)


Regards

Martin

Rory
September 27th, 1999, 06:59 AM
Thanks.
Is there a way that a I can use IDB_BITMAP as a background,
and load IDB_ABITMAP and IDB_ANOTHERBITMAP on top of it at some custom coordinates?

Thanks again

Rory Condon
Lead Programmer Anarchic Chicken Software
http://www.anarchic-chicken.8m.com

martho
September 27th, 1999, 11:18 AM
.. you can make another memDC, then selecting there the other bitmaps and then bitblt them to the memDc. Try something like

CDC otherMemDc;
otherMemDc.CreateCompatibleDC(&memdc)
CBitmap oldBmp2 = otherMemDc.SelectObject(otherBitmap);
memDc.bitblt(..... otherMemDc....);

Martin

memD

Rory
September 28th, 1999, 07:44 AM
I'm not sure what I'm doing wrong, but the code doesn't seem to be working. I am trying to print a bitmap with text on top of it. This is the code I have so far:CDC PrinterDC;
CPrintDialog printDlg(FALSE | PD_ALLPAGES | PD_NOPAGENUMS | PD_HIDEPRINTTOFILE | PD_NOSELECTION);

if(printDlg.DoModal() == ID_CANCEL)
return;

PrinterDC.Attach(printDlg.GetPrinterDC());

// Code to put bitmap into PrinterDC
CBitmap aBitmap;
aBitmap.LoadBitmap(IDB_BITMAP);
PrinterDC.SelectObject(&aBitmap);

// Code to print PrinterDC goes here

After that code I put the PrinterDC.TextOut calls and then print.
When this is printed the text displayed by TextOut prints but the bitmap is not there.
What am I doing wrong?

Thanks a lot.

Rory Condon
Lead Programmer Anarchic Chicken Software
http://www.anarchic-chicken.8m.com

Rory
September 28th, 1999, 04:31 PM
Sorry, since writing that last message I have discovered
that no graphics are printing. The TextOut()s are showing
but if I try MoveTo() followed by LineTo()s it doesn't
draw them either. Is there a way to switch the CDC into
graphics mode? Or is it a different problem?

Rory Condon
Lead Programmer Anarchic Chicken Software
http://www.anarchic-chicken.8m.com
rory@anarchic-chicken.8m.com