Click here to Skip to main content
15,896,269 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
JokeRe: help me please Pin
Rajesh R Subramanian6-May-08 1:00
professionalRajesh R Subramanian6-May-08 1:00 
JokeRe: help me please Pin
CPallini6-May-08 1:04
mveCPallini6-May-08 1:04 
AnswerRe: help me please Pin
sofia_1116-May-08 5:37
sofia_1116-May-08 5:37 
QuestionHelp! How to convert an array to bitmap? Pin
npkinh6-May-08 0:30
npkinh6-May-08 0:30 
AnswerRe: Help! How to convert an array to bitmap? Pin
ThatsAlok6-May-08 0:35
ThatsAlok6-May-08 0:35 
GeneralRe: Help! How to convert an array to bitmap? Pin
npkinh6-May-08 1:00
npkinh6-May-08 1:00 
GeneralRe: Help! How to convert an array to bitmap? Pin
Nelek6-May-08 2:02
protectorNelek6-May-08 2:02 
AnswerRe: Help! How to convert an array to bitmap? Pin
Mark Salsbery6-May-08 5:11
Mark Salsbery6-May-08 5:11 
What do you mean by "bitmap"? there's lots of different ways to represent
bitmap images Smile | :)

If you meant a Windows DDB bitmap (HBITMAP), then you could use a DIBSection.
A DIBSection gives you all the features of a device independent bitmap (DIB) through
a HBITMAP, along with a pointer to the pixel data bits, which you can work with directly.

Here's an example with a grayscale color table:
LONG lImageWidth = 640;
LONG lImageHeight = 480;
WORD wBitsPerPixel = 8;

LONG lBytesPerRow = (((lImageWidth * (long)wBitsPerPixel + 31L) & (~31L)) / 8L);

BITMAPINFO *bm = (BITMAPINFO *)new BYTE[sizeof(BITMAPINFO) + 255 * sizeof(RGBQUAD)];

bm->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bm->bmiHeader.biWidth = lImageWidth;
bm->bmiHeader.biHeight = lImageHeight;
bm->bmiHeader.biPlanes = 1;
bm->bmiHeader.biBitCount = wBitsPerPixel;
bm->bmiHeader.biCompression = BI_RGB;
bm->bmiHeader.biSizeImage = 0;
bm->bmiHeader.biXPelsPerMeter = 0;
bm->bmiHeader.biYPelsPerMeter = 0;
bm->bmiHeader.biClrUsed = 0;
bm->bmiHeader.biClrImportant = 0;

for (int color_index = 0; color_index < 256; color_index++)
{
    bm->bmiColors[color_index].rgbBlue = color_index;
    bm->bmiColors[color_index].rgbGreen = color_index;
    bm->bmiColors[color_index].rgbRed = color_index;
    bm->bmiColors[color_index].rgbReserved = 0;
}

BYTE *pBitmapBits;
HBITMAP hBitmap = ::CreateDIBSection(NULL, bm, DIB_RGB_COLORS, (void**)&pBitmapBits, NULL, 0);

if (hBitmap)
{
    // do something with the DIBSection

    ::DeleteObject(hBitmap);
}

delete[] (BYTE *)bm;



Mark

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

QuestionHow to Convert Local time to UTC Time in WM5.0 [modified] Pin
Mohanraj D6-May-08 0:14
Mohanraj D6-May-08 0:14 
AnswerRe: How to Convert Local time to UTC Time in WM5.0 Pin
perle16-May-08 1:22
perle16-May-08 1:22 
GeneralRe: How to Convert Local time to UTC Time in WM5.0 Pin
Mohanraj D6-May-08 1:36
Mohanraj D6-May-08 1:36 
AnswerRe: How to Convert Local time to UTC Time in WM5.0 [modified] Pin
Rajkumar R6-May-08 1:55
Rajkumar R6-May-08 1:55 
AnswerRe: How to Convert Local time to UTC Time in WM5.0 Pin
Rajesh R Subramanian6-May-08 2:03
professionalRajesh R Subramanian6-May-08 2:03 
GeneralRe: How to Convert Local time to UTC Time in WM5.0 Pin
Rajkumar R6-May-08 2:10
Rajkumar R6-May-08 2:10 
JokeRe: How to Convert Local time to UTC Time in WM5.0 Pin
Rajesh R Subramanian6-May-08 2:11
professionalRajesh R Subramanian6-May-08 2:11 
QuestionCompress Drive Pin
john56325-May-08 23:54
john56325-May-08 23:54 
AnswerRe: Compress Drive Pin
toxcct6-May-08 0:04
toxcct6-May-08 0:04 
QuestionRe: Compress Drive Pin
Rajesh R Subramanian6-May-08 0:22
professionalRajesh R Subramanian6-May-08 0:22 
AnswerRe: Compress Drive Pin
Rajkumar R6-May-08 0:42
Rajkumar R6-May-08 0:42 
QuestionSendMessage compatible with DLL Pin
tony_Udz5-May-08 23:46
tony_Udz5-May-08 23:46 
QuestionRe: SendMessage compatible with DLL Pin
Rajkumar R6-May-08 3:55
Rajkumar R6-May-08 3:55 
QuestionVC++6.0 How retrieve current row in a .DOC file? Pin
Antonio29295-May-08 23:36
Antonio29295-May-08 23:36 
AnswerRe: VC++6.0 How retrieve current row in a .DOC file? Pin
Nelek6-May-08 1:59
protectorNelek6-May-08 1:59 
GeneralRe: VC++6.0 How retrieve current row in a .DOC file? Pin
Antonio29296-May-08 3:25
Antonio29296-May-08 3:25 
GeneralRe: VC++6.0 How retrieve current row in a .DOC file? Pin
Nelek6-May-08 11:04
protectorNelek6-May-08 11:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.