displaying 24 bits DIB bitmap

displaying 24 bits DIB bitmap

Post by Eric Anterrie » Wed, 07 Jan 1998 04:00:00



I'm quite new to C++Builder and windows programming in general, and I
was wondering if there is a way to display a 24-bit bitmap (as device
independantly as possible) in a TImage by using a minimum calls to win32
functions and when the 24-bit bitmap is not stored in a .bmp file but
pointed to by three char* ?

The code that I am using now is:

void ViewImage(char R[], char G[], char B[])
{
static   HBITMAP  bmp24=NULL;
char     RGB[256*256*3];
int      i, j = 0;

for (i=0; i<256; i++)
  {RGB[j++] = R[i]; RGB[j++] = G[i]; RGB[j++] = B[i];}

if (bmp24 != NULL)
  {
  SelectObject(Form->Image->Canvas->Handle,bmp24);
  DeleteObject(bmp24);
  }
bmp24 = CreateBitmap(256,256,1,24,(void *) RGB);
Form->Image->Picture->Bitmap->Handle = bmp24;

Quote:}

It is quicker than using Form->Image->Canvas->Pixels by a factor 50,
but the HBITMAP created is not a DIB bitmap (bad), and every time
this function is called bmp24 is destroyed and created again (bad).

Can anyone describe (with source if possible) how I should proceed
more efficiently with only calls to VCL (if possible) ?
I think (may be I'm wrong) it could be possible to use TBitmap method
LoadFromStream (since TStream can be used for files and/or memory) in
conjunction with TBlobField (?), but up to now I didn't find any
solution...

Any help is appreciated. Thanks.

Eric

 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\
|                                                                 |
| Eric Anterrieu (Signal & Image Processing Team)                 |
| CERFACS, 42 av. Gaspard Coriolis, 31057 TOULOUSE Cedex, FRANCE  |
| phone.....: (+33) 05-6119-3078 (direct) or (+33) 05-6119-3131   |
| fax.......: (+33) 05-6119-3000                                  |

| web.......: http://www.cerfacs.fr                               |
-------------------------------------------------------------------
| Eric Anterrieu (Signal & Image Processing Team)                 |
| OMP/UMR 5572, 14 av. Edouard Belin, 31400 TOULOUSE, FRANCE      |
| phone.....: (+33) 05-6133-2882 (direct) or (+33) 05-6133-2929   |
| fax.......: (+33) 05-6133-2840                                  |

| web.......: http://www.obs-mip.fr                               |
|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/