Link to home
Start Free TrialLog in
Avatar of Tomb64
Tomb64

asked on

DIB to DIB

how can I copy the BitBlt and StretchBlt, but from a DIB to a DIB?

I would like a Win32 API, but C/C++ code to manually do that would be fine, if its decently fast
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nietod
nietod

BITMAPINFO SrcBmp = {??????};
void *SrcDat = ????;
BITMAPINFO DstBmp;
int DatSiz;
void *DstDat;

DatSiz = SrcBmp.bmiHeader.biSizeImage;

if (DatSiz == 0)
{
   int BitWdt = SrcBmp.bmiHeader.biBitCount * SrcBmp.bmiHeader.biWidth;
  int BytWdt = ((BitWdt >> 3)+ 3) && 0XFFFFFFFC
  DatSiz = BytWdt*SrcBmp.bmiHeader.biHeight;
}
DstDat = new char[DatSiz];

DstBmp = SrcBmp;
memcpy(DstDat,SrcDat,DatSiz);

continues
Its harder if you want to copy only a portion of the DIB or change its storage format.   While you can do this by copying the information manually, like a complex version of the example above.  i think the easest way would be to just copy the image from the source DIB to a memory DC using SetDIBIts() and then copy image out the memory DC to a destination DIB in the new format using GetDIBits().  
***Blt work with CreateDIBSection().