OLE_COLOR format

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, helmut, xnview

Andy

OLE_COLOR format

Post by Andy »

Hello!

I just can't figure out these OLE colors - I've tried many things using the object.ReplaceColor but none of them worked for me. What I need is to replace #CCCCCC, &HCCCCCC, RGB (204,204,204) ,... with white color. My all tries just return "Bad parameters" using ASP, GFLAX.

Can someone write me a line how to do that?
object.ReplaceColor(Color As OLE_COLOR, NewColor As OLE_COLOR, [Tolerance As Long])
Thank you so much!!

Andy
User avatar
xnview
Author of XnView
Posts: 44761
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: OLE_COLOR format

Post by xnview »

Andy wrote:Hello!

I just can't figure out these OLE colors - I've tried many things using the object.ReplaceColor but none of them worked for me. What I need is to replace #CCCCCC, &HCCCCCC, RGB (204,204,204) ,... with white color. My all tries just return "Bad parameters" using ASP, GFLAX.

Can someone write me a line how to do that?
object.ReplaceColor(Color As OLE_COLOR, NewColor As OLE_COLOR, [Tolerance As Long])
Thank you so much!!
You have an error when you try :
ReplaceColor RGB(204,204,204), RGB(255, 255, 255)
Pierre.
Guest

Re: OLE_COLOR format

Post by Guest »

You have an error when you try :
ReplaceColor RGB(204,204,204), RGB(255, 255, 255)
Yes,this is the response:

GflAx.GflAx.1 error '80004005'
Bad parameters
/example/image.asp, line 87

.. the picture is loaded ..
sir.ReplaceColor RGB(204,204,204), RGB(255, 255, 255) <- line 87 in ASP
sir.Crop areaX1, areaY1, areaX2, areaY2 <- line 88

Line 88 and others go fine when line 87 is not in use.

I tried to find a workaround using double For..Next statement scanning the picture and sir.getColorAt(slx,sly) / condition / sir.drawPoint slx, sly. What I found out is that sir.getColorAt(slx,sly) can not be used without converting to LONG (CLNG), so plain usege returns Variable_uses_an_Automation_type_not_supported_in_VBScript.

The values I get back from CLNG(sir.getColorAt(slx,sly)) are e.g. 7012533,16711935,18943,45823,65535,586496,1100544,3252736,16727040,10262016,14077696,16776960 but using them in above For..Next statements does not replace every value, just some. As if there were error in converting to LONG (the manual transform from RGB (r,g,b) to the given nnnnnnnnn is not the same).

SO even this try, that takes too much CPU time using scripting language, does not work 100% for me.

I hope that I helped a bit to the solution of another mistery of your masterpiece! Or that might be just my stupidness? :wink: Thanks again!

Andy
User avatar
xnview
Author of XnView
Posts: 44761
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: OLE_COLOR format

Post by xnview »

Anonymous wrote:
You have an error when you try :
ReplaceColor RGB(204,204,204), RGB(255, 255, 255)
Yes,this is the response:

GflAx.GflAx.1 error '80004005'
Bad parameters
/example/image.asp, line 87

.. the picture is loaded ..
sir.ReplaceColor RGB(204,204,204), RGB(255, 255, 255) <- line 87 in ASP
sir.Crop areaX1, areaY1, areaX2, areaY2 <- line 88

Line 88 and others go fine when line 87 is not in use.

I tried to find a workaround using double For..Next statement scanning the picture and sir.getColorAt(slx,sly) / condition / sir.drawPoint slx, sly. What I found out is that sir.getColorAt(slx,sly) can not be used without converting to LONG (CLNG), so plain usege returns Variable_uses_an_Automation_type_not_supported_in_VBScript.

The values I get back from CLNG(sir.getColorAt(slx,sly)) are e.g. 7012533,16711935,18943,45823,65535,586496,1100544,3252736,16727040,10262016,14077696,16776960 but using them in above For..Next statements does not replace every value, just some. As if there were error in converting to LONG (the manual transform from RGB (r,g,b) to the given nnnnnnnnn is not the same).

SO even this try, that takes too much CPU time using scripting language, does not work 100% for me.

I hope that I helped a bit to the solution of another mistery of your masterpiece! Or that might be just my stupidness? :wink: Thanks again!

Andy
Houps, sorry i forgot a parameter (tolerance)
ReplaceColor RGB(204,204,204), RGB(255, 255, 255), 1
Pierre.
Andy

OLE_COLOR

Post by Andy »

So sorry to report the same error again:
GflAx.GflAx.1 error '80004005'
Bad parameters
The tolerance parameter should be optional according to the manual?

Let me describe the environment: Win 2003 Server, GflAx 2.40, object defined as

Code: Select all

Set sir = Server.CreateObject("GflAx.GflAx")
, ASP page using for replacing the shaddowed area with white color..

Did you try this ReplaceColor line using ASP and GflAx 2.40?

Thanks,

Andy
drcool
Posts: 1
Joined: Tue Jun 19, 2007 6:32 am

ReplaceColor() "Bad parameters" problem solved

Post by drcool »

I had the exact same problem and was able to figure it out. I kept getting the "Bad parameters" error no matter what I tried.

It turns out the problem is that I was trying to replace a color on a 1-bit GIF image. The new replacement color wasn't part of the GIF's palette. I had to first do a ChangeColorDepth command to get it to TrueColor, then replace the color, then change the color depth again back down to 1-bit. That worked.

By the way, don't let the "OLE_COLOR" thing confuse you like it did me. I was hunting around to find a converter thinking I was feeding it bad numbers. Just use the command "RGB(r,g,b)" and you're good to go.