BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using Color Profiles (ICM) to Change Bitmaps

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Eric Winter
Guest





PostPosted: Wed May 09, 2007 3:26 am    Post subject: Using Color Profiles (ICM) to Change Bitmaps Reply with quote



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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.