Thread: deleting this bitmap

  1. #1
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161

    deleting this bitmap

    in a large programme i'm making i've decided to display an image, but i don't want it be seen forever so i wondered if anybody knew how the deleting the image that is displayed from the code below.

    Code:
    LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	HANDLE hFile;
        HDC hdc;
        PAINTSTRUCT ps;
        TEXTMETRIC tm;
        SIZE size;
        HFONT font;
        
        static BITMAPFILEHEADER *pbmfh;
        static BITMAPINFO *pbmi;
        static BYTE *pBits;
        static int cxDib, cyDib;
        switch (message)   
    	switch(message)
    	{
    
    	case WM_PAINT:
    	DWORD dwFileSize, dwHighSize, dwBytesRead;
    	hFile = CreateFile ("E:\\image.BMP", GENERIC_READ,
    	                   FILE_SHARE_READ, NULL,
    	                   OPEN_EXISTING,
    	                   FILE_FLAG_SEQUENTIAL_SCAN,
    	                   NULL);
        dwFileSize = GetFileSize (hFile, &dwHighSize);
        pbmfh = (BITMAPFILEHEADER *) malloc (dwFileSize);
        ReadFile (hFile, pbmfh, dwFileSize,
                 &dwBytesRead, NULL);
        pbmi = (BITMAPINFO *) (pbmfh + 1);
        pBits = (BYTE *) pbmfh + pbmfh->bfOffBits;
        cxDib = pbmi->bmiHeader.biWidth;
        cyDib = abs(pbmi->bmiHeader.biHeight);
        HDC hdc;
        hdc = GetDC (hwnd);
        
        SetDIBitsToDevice (hdc,
                         0,
                         250,
                         cxDib,
                         cyDib,
                         
                         0,
                         0,
                         0,
                         cyDib,
                         pBits,
                         pbmi,
                         DIB_RGB_COLORS);
        ReleaseDC (hwnd, hdc);
        free (pbmfh);
    
    	return 0;
    I started out with nothing and I still have most of it left.

  2. #2
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161
    whoops never mind, i found out how to.
    I started out with nothing and I still have most of it left.

  3. #3
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    cool.. I have the same question.. i'm thinking about coding up a game of texas holdem'.. and I want to display and remove bitmap images of cards.. I was thinking about using InvalidateRect( ) to repaint the entire window.. but this seems kinda inefficient.. what method did you use?
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  4. #4
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161
    i used a whole different way. I used resources.

    And then to delete it i used deleteobject()
    I started out with nothing and I still have most of it left.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loading a bitmap (Without using glaux)
    By Shamino in forum Game Programming
    Replies: 7
    Last Post: 03-16-2006, 09:43 AM
  2. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  3. bitmap not going onto screen
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 02-22-2003, 10:07 AM
  4. Deleting HDC w/ bitmap selected
    By Hunter2 in forum Windows Programming
    Replies: 15
    Last Post: 12-09-2002, 05:36 PM
  5. texture is all white in opengl!
    By Crossbow in forum Game Programming
    Replies: 7
    Last Post: 03-31-2002, 11:54 AM