Hello,
can someone explain how i can get a 24bit bitmap
to display in other display modes, my program
opens a third party data file that stores some bitmaps
in parts of it, the bitmap is stored as bgr raw data
i read this data and flip the bytes to rgb, then use
CreateBitmap(256,256,1,24,buf);
everything works fine in my program as long as my display
is set to 24bit color mode, any other mode i get a junk bitmap
or nothing...
i need a way to convert the bitmap to be compatible with
the screen and still be able to save the 24bit data to save back to
the file after modified
What other modes are you trying to use?, 32 bit or lower modes and can you post an example rubbish bitmap display. It will help to understand what is happening.
Requests such as
"I need to write an new language compiler by next week, I have teach yourself c++ in 21 days, can someone give me example code?" will be ignored.
this works if my display is 24bit color i get a 256x256 image with
the correct image displayed.
if i have my display set to 16bit color or 256 color i get an image
that contains some graphics from windows it contains the window icons
the close button in different states like pressed,depressed...
as long as my display is set to 24bit color everthing on my program works
thanks for help,
So the icons are different as well or just the colours?
Can you show how this bitmap is used when displaying?
Requests such as
"I need to write an new language compiler by next week, I have teach yourself c++ in 21 days, can someone give me example code?" will be ignored.
if(m_Combo1.GetCount()>0)
{
int i = m_Combo1.GetCurSel();
if(bm1 != NULL)
DeleteObject(bm1);
bm1 = CreateBitmapIndirect(m_BitmapArray.GetAt(i));
CDC pDC;
pDC.CreateCompatibleDC(NULL);
HBITMAP old;
VERIFY(old = (HBITMAP)SelectObject(pDC.m_hDC,bm1));
int sel = m_Combo2.GetCurSel();
int x = m_Texture_records.at(sel).X1;
int y = m_Texture_records.at(sel).Y1;
int w = m_Texture_records.at(sel).Width;
int h = m_Texture_records.at(sel).Height;
CRect rect2;
rect2.top = y;
rect2.left = x;
rect2.right = w+x+1;
rect2.bottom = h+y+1;
if(m_Check1.GetCheck())
{
for(int i=0; i<256; i+=m_Down)
{
for(int a=0; a<256; a+=m_Across)
{
pDC.Draw3dRect(a,i,m_Across,m_Down,m_GridColor,m_GridColor);
}
}
}
pDC.Draw3dRect(&rect2,m_SelColor,m_SelColor);
SelectObject(pDC.m_hDC,old);
m_Bitmap1.SetBitmap(bm1);
DeleteObject(old);
pDC.DeleteDC();
m_strPages.Format("page %d of %d",i+1,m_Combo1.GetCount());
UpdateData(FALSE);
}
i get a error in debug mode from the first SelectObject if i run in other than 24bit mode
the image supose to look like the attached one below not the one with buttons
thanks,
I suspec this call pDC.CreateCompatibleDC(NULL); is failing. Check the return from this call first.
Requests such as
"I need to write an new language compiler by next week, I have teach yourself c++ in 21 days, can someone give me example code?" will be ignored.
hey Bob,
i've done alot of test, everything returns successful,
everything i tried points me to the CreateBitmap to be the problem
i can load a 24bit bitmap and it will display properly in other modes,
but the bitmap i create with CreateBitmap dosen't display properly
if my display isn't set to 24bit color mode...
i need to know of another function i can use to create an HBITMAP
from an rgb buffer that will work in any display mode
or another thing i can try is convert my rgb buffer from 24bit to 16bit
is the user's display isn't 24bit but i don't know how it's formated
i know 24bit is bgr 3 bytes each pixel but how's 16bit...
Requests such as
"I need to write an new language compiler by next week, I have teach yourself c++ in 21 days, can someone give me example code?" will be ignored.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.