Jump to content
  • Advertisement
Sign in to follow this  
Ohmy

Ok...i have a problem

This topic is 5153 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

(MFC)
// Create A Temporary Bitmap
BITMAPINFO bi = {0}; // The Type Of Bitmap We Request

DWORD *pBits = 0; // Pointer To The Bitmap Bits
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi.bmiHeader.biBitCount = 32; 
bi.bmiHeader.biWidth = TextureCopy[0]->sizeX;
bi.bmiHeader.biHeight = TextureCopy[0]->sizeY;
bi.bmiHeader.biCompression = BI_RGB;
bi.bmiHeader.biPlanes = 1;


hdcTemp = CreateCompatibleDC(0);
hbmpTemp = ::CreateDIBSection(hdcTemp, &bi, DIB_RGB_COLORS, (void**)&pBits,0,0);

for(int y = 0;y < TextureCopy[0]->sizeY * TextureCopy[0]->sizeX;y++)
{

Myclr.red = TextureCopy[0]->data[y * (1)];
Myclr.green = TextureCopy[0]->data[(y * (1)) + 1];
Myclr.blue = TextureCopy[0]->data[(y * (1)) + 2];
Myclr.alpha = 255;

memcpy(&pBits[(y)],&Myclr,sizeof(ULONG));

}

SelectObject(hdcTemp,hbmpTemp);

----------------
..later...
CDC temp;

temp.Attach(hdcTemp); 

...........

// Paint Code :

GetClientRect(&rect);

dc.BitBlt(rect.left,rect.top,rect.right,rect.bottom,&temp,0,0,SRCCOPY);

Ok...my problem is...i want to display a bitmap...My code works but the problem is...it displays it black/white...Instead of color???? [Edited by - Ohmy on August 16, 2004 7:10:38 PM]

Share this post


Link to post
Share on other sites
Advertisement
Try giving the DC of a window that you have created to CreateCompatiableDC instead of NULL (like the one you're going to blit the bitmap to), ie:


HDC hDC = GetDC(hWnd);
hdcTemp = CreateCompatibleDC(hDC);
ReleaseDC(hDC, hWnd);

Share this post


Link to post
Share on other sites
CreateCompatibleDC(NULL)/*or 0*/looks alright to me(the same as the current display surface)
-try adding:
bi.bmiHeader.biClrUsed=0;/*true colors*/
bi.bmiHeader.biClrImpotant=0;/*all colors are important*/


I hope it works.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!