CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Bitmaps

  1. #1
    Join Date
    Aug 1999
    Location
    England
    Posts
    37

    Bitmaps

    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

  2. #2
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    2,338

    Re: Bitmaps

    .. just try:

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


    Regards

    Martin


  3. #3
    Join Date
    Aug 1999
    Location
    England
    Posts
    37

    Re: Bitmaps

    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

  4. #4
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    2,338

    Re: Bitmaps

    .. 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




  5. #5
    Join Date
    Aug 1999
    Location
    England
    Posts
    37

    Re: Bitmaps

    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

  6. #6
    Join Date
    Aug 1999
    Location
    England
    Posts
    37

    Re: Bitmaps

    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
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured