| Author | Topic: XbpBitmap() and Transparency |
---|
| Itai Ben-Artzi | XbpBitmap() and Transparency
on Fri, 20 Jul 2018 00:25:55 -0700Hi Alaska,
Could you please show a snippet code reading an image-file and saving
it transparent (the documentation on this is confusing)?
For example:
oImage := XbpBitmap():New():create()
oimage:loadfile(cFile)
Do something
oimage:saveFile( cNewFile, XBPBMP_FORMAT_PNG, Nil )
Many thanks,
-Itai |
| Carlos a Beling | Re: XbpBitmap() and Transparency
on Fri, 20 Jul 2018 10:03:21 -0300Hello Itai.
Good morning.
As far as I know the transparency is defined before to draw the image
and can to be any color.
Please see in the docs:
XbpBitmap:transparentClr ("...that should be displayed transparent by
the :draw() method...")
XbpBitmap:transparency ("...specifies the level of transparency to
apply when displaying the image via the method :draw()...")
Fraternally
Beling
Em 20/07/2018 04:25, Itai Ben-Artzi escreveu:
> Hi Alaska,
> Could you please show a snippet code reading an image-file and saving
> it transparent (the documentation on this is confusing)?
> For example:
> oImage := XbpBitmap():New():create()
> oimage:loadfile(cFile)
> Do something
> oimage:saveFile( cNewFile, XBPBMP_FORMAT_PNG, Nil )
>
> Many thanks,
> -Itai
> |
| Itai Ben-Artzi | Re: XbpBitmap() and Transparency
on Fri, 20 Jul 2018 08:47:07 -0700Thank you, Carlos.
There is no need to draw the image; only to save it as transparent.
The documentation there is obviously written by very smart Peoples
because an ordinary person like me cannot understand it. Is there a
snippet code showing how to convert a white background to transparent?
Many thanks,
-Itai |
| Carlos a Beling | Re: XbpBitmap() and Transparency
on Fri, 20 Jul 2018 18:29:42 -0300Hello Itai.
Good evening.
Some time ago Mr Jose Antonio Diego Kereje posted in 03.05.2018 in the
GUI NG the attache program that may to be useful for you.
Fraternally
Beling
Em 20/07/2018 12:47, Itai Ben-Artzi escreveu:
> Thank you, Carlos.
> There is no need to draw the image; only to save it as transparent.
> The documentation there is obviously written by very smart Peoples
> because an ordinary person like me cannot understand it. Is there a
> snippet code showing how to convert a white background to transparent?
> Many thanks,
> -Itai
> TesteIco.zip |
| Itai Ben-Artzi | Re: XbpBitmap() and Transparency
on Fri, 20 Jul 2018 15:40:29 -0700Thank you, Carlos!!!
I am going to study this.
-Itai |
| Itai Ben-Artzi | Re: XbpBitmap() and Transparency
on Sat, 21 Jul 2018 01:10:25 -0700Carlos,
The sample by Jose only handles a :Draw(), but PNG files are corrupted
and not usable.
The Windows Image Acquisition (WIA) is a nice discovery for me, but
even Microsoft do not provide a method to set transparent image. A
few articles suggest using the ARGBData to manipulate the
AlphaChannel, but I could not find a method that can do that. It
would be nice if Alaska enable such a function or method.
-Itai |
| Carlos a Beling | Re: XbpBitmap() and Transparency
on Thu, 26 Jul 2018 10:46:35 -0300Hello Itai.
Good morning.
Please see the function STATIC FUNCTION AdjustsAlpha( oBmp ).
Lines 36 to 47 may to be useful for you:
IF nCont = 1
oBitmap:destroy()
oBitmap:= Icon2Bmp( oIcon, GraMakeRGBColor( {
TRANSPARENT_CLR_TAG, TRANSPARENT_CLR_TAG, TRANSPARENT_CLR_TAG } ) )
cFile:= cPath + 'test' + Str( nInd, 4 ) + '.bmp'
FErase( cFile )
oBitmap:saveFile( cFile, XBPBMP_FORMAT_WIN3X )
cFile:= cPath + 'test' + Str( nInd, 4 ) + '.bmp'
CreatePNG( cFile, StrTran( cFile, 'bmp', 'png' ) )
FErase( cFile )
ENDIF
Fraternally
Beling
Em 21/07/2018 05:10, Itai Ben-Artzi escreveu:
> Carlos,
> The sample by Jose only handles a :Draw(), but PNG files are corrupted
> and not usable.
> The Windows Image Acquisition (WIA) is a nice discovery for me, but
> even Microsoft do not provide a method to set transparent image. A
> few articles suggest using the ARGBData to manipulate the
> AlphaChannel, but I could not find a method that can do that. It
> would be nice if Alaska enable such a function or method.
>
> -Itai
> |
| Itai Ben-Artzi | Re: XbpBitmap() and Transparency
on Sun, 29 Jul 2018 21:34:34 -0700Thank you, Carlos, but this is not working:
1. Saving oBitmap as BMP preserves alphachannel, but transparency and
transparency-color are dropped.
2. Saving the oBitmap as PNG or GIF causes the saved file to drop the
alphachanel, transparency and transparency color.
I could not find a way to read a picture and save it as transparent
PNG. It seems Alaska shall improve the saving format of the image.
-Itai |
| Jose Antonio Diego Kereje | Re: XbpBitmap() and Transparency
on Mon, 30 Jul 2018 14:36:37 +0200Back to work!!!
This sample replicates the "standard use" of xbpbitmap but at the file level
(oBmp:transparentClr:= oBmp:getDefaultBGColor() )
Regards. Diego Test.zip |
| Itai Ben-Artzi | Re: XbpBitmap() and Transparency
on Mon, 30 Jul 2018 11:41:54 -0700Thank you! Thank you!!
Works great! Alaska still shows ::transparency = 0 instead of 255,
but it seems a bug in Alaska's object.
Again, thank you for the solution, Diego.
-Itai |
| Jose Antonio Diego Kereje | Re: XbpBitmap() and Transparency
on Mon, 30 Jul 2018 23:06:20 +0200Hi,
> Works great! Alaska still shows ::transparency = 0 instead of 255,
> but it seems a bug in Alaska's object.
No, that is correct since the global transparency applied is not saved in
the file. What is stored is the result of applying it to the alpha channel
of each pixel.
Check it in the new sample.
Regards. Diego Test.zip |
| Carlos a Beling | Re: XbpBitmap() and Transparency
on Tue, 31 Jul 2018 18:03:59 -0300Hello Diego.
Good evening.
Please, is it needed to know the existence of the alpha chanel before to
execute MakeTransparent()? if yes, can you showing ho?
Beling
Best regards
Em 30/07/2018 18:06, Jose Antonio Diego Kereje escreveu:
> Hi,
>
>> Works great! Alaska still shows ::transparency = 0 instead of 255,
>> but it seems a bug in Alaska's object.
>
> No, that is correct since the global transparency applied is not saved
> in the file. What is stored is the result of applying it to the alpha
> channel of each pixel.
>
> Check it in the new sample.
>
> Regards. Diego |
| Jose Antonio Diego Kereje | Re: XbpBitmap() and Transparency
on Wed, 01 Aug 2018 19:22:40 +0200Hello Carlos,
Not to execute it, but to obtain a correct result, yes.
Regards. Diego Test.zip |
| Carlos a Beling | Re: XbpBitmap() and Transparency
on Wed, 01 Aug 2018 18:29:31 -0300Hello Diego.
Good night.
Many many thanks again.
Fraternally
Beling
Em 01/08/2018 14:22, Jose Antonio Diego Kereje escreveu:
> Hello Carlos,
>
> Not to execute it, but to obtain a correct result, yes.
>
> Regards. Diego |