I am trying to display a bitmap 
Author Message
 I am trying to display a bitmap

I have tried and tried and I can not get a bitmap to display on the screen.
CAn You show me a better way?
 Thank you.

  HBITMAP aBMap;
  HBITMAP bBMap;
  HBITMAP holdbm;
  HBITMAP hnewbm;
  HDC hmemorydcNew;
  HDC hmemorydcOld;
  HDC hdc;
 // CDC* adc;
//  HBITMAP m_hbmpPodium;
//  HBITMAP m_hbmpScreen;
//  HBITMAP m_hbmpDoor;
//  HBITMAP m_hbmpDisplay;
//  HBITMAP m_hbmpChair;
//  HBITMAP m_hbmpAisle;

 // adc=GetDC();
  hdc=context->m_hDC;

  hmemorydcNew=CreateCompatibleDC(hdc);
  hmemorydcOld=CreateCompatibleDC(hdc);

  bBMap=CreateCompatibleBitmap(hdc,100,100);
  aBMap=(HBITMAP)::LoadBitmap(myInstance,"res\\wallindexi.bmp");

  holdbm=(HBITMAP)SelectObject(hmemorydcNew, bBMap);
  hnewbm=(HBITMAP)SelectObject(hmemorydcOld, aBMap);

  StretchBlt(hmemorydcNew,0,0,100,100,hmemorydcOld,0,0,32,32,SRCCOPY);

  SelectObject(hmemorydcNew,holdbm);
  SelectObject(hmemorydcOld,hnewbm);

  DeleteDC(hmemorydcNew);
  DeleteDC(hmemorydcOld);



Sat, 09 Dec 2000 03:00:00 GMT  
 I am trying to display a bitmap

One way is to develop a dialog in the resource editor and add a picture control
(i.e., call it IDC_TEST_IMAGE).  Then add whatever bitmap you want to the
bitmap to the resources (IDB_TEST_BITMAP).  Then get a pointer to this picture
control casting to CStatic*.  Next, load the bitmap from the exectuable file
using LoadBitmap.  And finally, add assign the bitmap to the window using
::SetBitmap.

CStatic  *window_to_display_in  = (CStatic *)GetDlgItem(IDC_TEST_IMAGE);
CBitmap   bitmap1;

bitmap1.LoadBitmap(MAKEINTRESOURCE(IDB_TEST_BITMAP));
window_to_display_in->SetBitmap(bitmap1);

Not sure if this is exactly what you were looking for but I hope it helps.

-Dan

Quote:

> I have tried and tried and I can not get a bitmap to display on the screen.
> CAn You show me a better way?
>  Thank you.

>   HBITMAP aBMap;
>   HBITMAP bBMap;
>   HBITMAP holdbm;
>   HBITMAP hnewbm;
>   HDC hmemorydcNew;
>   HDC hmemorydcOld;
>   HDC hdc;
>  // CDC* adc;
> //  HBITMAP m_hbmpPodium;
> //  HBITMAP m_hbmpScreen;
> //  HBITMAP m_hbmpDoor;
> //  HBITMAP m_hbmpDisplay;
> //  HBITMAP m_hbmpChair;
> //  HBITMAP m_hbmpAisle;

>  // adc=GetDC();
>   hdc=context->m_hDC;

>   hmemorydcNew=CreateCompatibleDC(hdc);
>   hmemorydcOld=CreateCompatibleDC(hdc);

>   bBMap=CreateCompatibleBitmap(hdc,100,100);
>   aBMap=(HBITMAP)::LoadBitmap(myInstance,"res\\wallindexi.bmp");

>   holdbm=(HBITMAP)SelectObject(hmemorydcNew, bBMap);
>   hnewbm=(HBITMAP)SelectObject(hmemorydcOld, aBMap);

>   StretchBlt(hmemorydcNew,0,0,100,100,hmemorydcOld,0,0,32,32,SRCCOPY);

>   SelectObject(hmemorydcNew,holdbm);
>   SelectObject(hmemorydcOld,hnewbm);

>   DeleteDC(hmemorydcNew);
>   DeleteDC(hmemorydcOld);



Sun, 10 Dec 2000 03:00:00 GMT  
 I am trying to display a bitmap

CMainView::OnDraw(CDC* pDC)
{
    // Load the bitmap
    CBitmap TempBitmap; TempBitmap.LoadBitmap(IDR_CHARIMAGE);

    // Create a mem DC.
    CDC dc; dc.CreateCompatibleDC(pDC);

    // Select the bitmap into the mem dc.
    CBitmap* pOldBitmap = dc.SelectObject(&TempBitmap);

    // Copy the bitmap to the view.
    pDC->StretchBlt(<x pos in view>, <y pos in view>, <width in view>, <height
in view>,
        &dc, 0, 0, <original width>, <original height>, SRCCOPY);

    // Select the old bitmap back into the mem dc (so no resource leak occurs).

    dc.SelectObject(pOldBitmap);

Quote:
}

If you are working with 256-color bitmaps, and you're not running in true color

mode, then this won't work like you want, because it isn't doing palette stuff.

Look at the DIBLOOK sample that comes with VC for samples of how to do that, if

you want. Hope this helps - Doug S.

Quote:

> I have tried and tried and I can not get a bitmap to display on the screen.
> CAn You show me a better way?
>  Thank you.

>   HBITMAP aBMap;
>   HBITMAP bBMap;
>   HBITMAP holdbm;
>   HBITMAP hnewbm;
>   HDC hmemorydcNew;
>   HDC hmemorydcOld;
>   HDC hdc;
>  // CDC* adc;
> //  HBITMAP m_hbmpPodium;
> //  HBITMAP m_hbmpScreen;
> //  HBITMAP m_hbmpDoor;
> //  HBITMAP m_hbmpDisplay;
> //  HBITMAP m_hbmpChair;
> //  HBITMAP m_hbmpAisle;

>  // adc=GetDC();
>   hdc=context->m_hDC;

>   hmemorydcNew=CreateCompatibleDC(hdc);
>   hmemorydcOld=CreateCompatibleDC(hdc);

>   bBMap=CreateCompatibleBitmap(hdc,100,100);
>   aBMap=(HBITMAP)::LoadBitmap(myInstance,"res\\wallindexi.bmp");

>   holdbm=(HBITMAP)SelectObject(hmemorydcNew, bBMap);
>   hnewbm=(HBITMAP)SelectObject(hmemorydcOld, aBMap);

>   StretchBlt(hmemorydcNew,0,0,100,100,hmemorydcOld,0,0,32,32,SRCCOPY);

>   SelectObject(hmemorydcNew,holdbm);
>   SelectObject(hmemorydcOld,hnewbm);

>   DeleteDC(hmemorydcNew);
>   DeleteDC(hmemorydcOld);



Sun, 10 Dec 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Displaying a bitmap vs. displaying its icon

2. C# , i am trying to create a file on the server using C#

3. Jeff, i am trying to connect......chuck

4. I am trying to Copy and Paste using COleDataObject

5. I am having problems setting up that a specified dialog is displayed before any others

6. simply trying to load a bitmap file

7. Trying to create a bitmap from an ole object

8. Toolbar drop-down menu problem trying to display popup menu (IE Deskbar)

9. Unable to display help - Tried the reg stuff it didn't work

10. Trying To Display A FrameWnd

11. I am new to programming and am lost

12. Displaying GIF and Bitmap Images in C#

 

 
Powered by phpBB® Forum Software