NO

Author Topic: GetDIBits  (Read 1047 times)

Grincheux

  • Guest
GetDIBits
« on: April 17, 2021, 06:06:09 pm »
In my filters editor I use GetDIBits to fill the bitmapinfoheader structure.

Code: [Select]
GetDIBits(_hDC,_hImgBitmap,0,_lpImageInfos->BitmapInfo.bmiHeader.biHeight,NULL,(LPBITMAPINFO) &_lpImageInfos->BitmapInfo,DIB_RGB_COLORS)
If all the six first parameters are well initialized, the next time I call GetDIBits, with the address of the buffer, rather than  NULL, all the image is read.

The idea is good but in that case GetDIBits fills a BITMAPINFOHEADERV5!
Use this function with care. Make something like this:

struct
{
   BITMAPINFO  Bmi ;
   char szTmp[sizeof(BITMAPINFOHEADERV5) - sizeof(BITMAPINFOHEADER)] ;
}

After the BITMAPINFOHEADER there is the color palette but it is not enougth

When I use the editor, BITMAPINFOHEADERV5 does not display its member, like other do, which *.tag file is it needed for that is OK?
« Last Edit: April 17, 2021, 06:09:04 pm by Grincheux »

Offline John Z

  • Member
  • *
  • Posts: 533
Re: GetDIBits
« Reply #1 on: April 18, 2021, 10:59:52 am »
Just looking - maybe it should be

char szTmp[sizeof(BITMAPV5HEADER) - sizeof(BITMAPINFOHEADER)] ;

based on Micro$oft:
The  BITMAPINFOHEADER v5.0 structure:
typedef struct {
   DWORD        bV5Size;
   LONG         bV5Width;
   LONG         bV5Height;
   WORD         bV5Planes;
   WORD         bV5BitCount;
   DWORD        bV5Compression;
   DWORD        bV5SizeImage;
   LONG         bV5XPelsPerMeter;
   LONG         bV5YPelsPerMeter;
   DWORD        bV5ClrUsed;
   DWORD        bV5ClrImportant;
   DWORD        bV5RedMask;
   DWORD        bV5GreenMask;
   DWORD        bV5BlueMask;
   DWORD        bV5AlphaMask;
   DWORD        bV5CSType;
   CIEXYZTRIPLE bV5Endpoints;
   DWORD        bV5GammaRed;
   DWORD        bV5GammaGreen;
   DWORD        bV5GammaBlue;
   DWORD        bV5Intent;
   DWORD        bV5ProfileData;
   DWORD        bV5ProfileSize;
   DWORD        bV5Reserved;
} BITMAPV5HEADER, FAR *LPBITMAPV5HEADER, *PBITMAPV5HEADER;

which is in Pelles C - wingdi.h

John Z

Grincheux

  • Guest
Re: GetDIBits
« Reply #2 on: April 18, 2021, 11:29:06 am »
Thank You John


I don't know what to add to the program.
It seems finished and I have not seem other bugs.
That does not want to say it has no bugs.


I am asking to myself if it is useful to add an histogram for the result.
The histogram now display correctly the Red, Green, Blue, RGB and Luminosity.


Offline John Z

  • Member
  • *
  • Posts: 533
Re: GetDIBits
« Reply #3 on: April 18, 2021, 02:35:22 pm »
A lot of work by you.  I'll need to grab the newest one.

Seems a before and after histogram might be useful to someone who invests time using filters.
in line with your motto "Never be pleased, always improve"  it would add value....

John Z