Eric Winter Guest
|
Posted: Wed May 09, 2007 3:26 am Post subject: Using Color Profiles (ICM) to Change Bitmaps |
|
|
hi,
i just translated icm.h to pascal code and tested it with small sniplet
microsoft provided.
all "read" functions work fine but everything else eg: CheckBitmapBits or
TranslateBitmapBits fails with "wrong parameter".
#################################################################
i first load profiles:
inputProfile := OpenColorProfileA(@profile1, PROFILE_READ,
FILE_SHARE_READ, OPEN_EXISTING);
outputProfile := OpenColorProfileA(@profile2, PROFILE_READ,
FILE_SHARE_READ, OPEN_EXISTING);
//works fine
then i creat a colortransform: (lcs: LOGCOLORSPACE)
GetLogColorSpace(GetColorSpace(Printer.Handle), lcs,
sizeof(LOGCOLORSPACE));
//printer.hande is just for testing purpose, --> in tried creating raw
sRGB profile but this fails so i use this
hColorTransform := CreateColorTransformA(@lcs, outputProfile,
inputProfile, BEST_MODE);
//works fine
but from this on, mothing will work:
GetObject(InputBitmap.Handle, sizeof(BITMAP), @inbmp);
GetObject(OutputBitmap.Handle, sizeof(BITMAP), @outbmp);
CheckBitmapBits(hColorTransform,
inbmp,
BM_RGBTRIPLETS,
inbmp.bmWidth,
inbmp.bmHeight,
0,
paResult,
nil,
0
);
//fails with "wrong parameter"
TranslateBitmapBits(hColorTransform,
inbmp.bmBits,
BM_RGBTRIPLETS,
inbmp.bmWidth,
inbmp.bmHeight,
0,
outbmp.bmBits,
BM_RGBTRIPLETS,
0,
nil,
0);
//also fails
#################################################################
my declaration is like:
function CheckBitmapBits(hColorTransform: HTRANSFORM;
pSrcBits: Pointer {VOID};
bmInput: BMFORMAT;
dwWidth: DWORD;
dwHeight: DWORD;
dwStride: DWORD;
var paResult: BYTE;
pfnCallback: BMCALLBACKFN;
lpCallbackData: DWORD
): Bool; stdcall;
function TranslateBitmapBits(hColorTransform: HTRANSFORM;
pSrcBits: Pointer;
bmInput: BMFORMAT;
dwWidth: DWORD;
dwHeight: DWORD;
dwInputStride: DWORD;
pDestBits: Pointer;
bmOutput: BMFORMAT;
dwOutputStride: DWORD;
pfnCallback: BMCALLBACKFN;
ulCallbackData: DWORD
): Bool; stdcall;
PBMCALLBACKFN = ^BMCALLBACKFN;
BMCALLBACKFN = function(a, b, c: DWORD): Boolean;
//icm.h:
//typedef BOOL (WINAPI *PBMCALLBACKFN)(ULONG, ULONG, ULONG);
Thanks in advance,
Yours Eric |
|