Partial transparency in created Timages

Archives Forums/BlitzMax Bug Reports/Partial transparency in created Timages

dw817(Posted 2016) [#1]


The partial water tiles are actually images that have not used GrabImage() after CreateImage()

This may not be so much a bug as an undocumented feature.

If you use the code: img:Timage=CreateImage(x,y)

This does NOT clear said created image to black pixels always.

YES it does in debug mode, NO it does not in regular compilation !

You must have GrabImage img,0,0 on an empty screen or something similar to ensure true black pixels for that image.

Not sure if this is a kick in the pants for programmers to remind them to clear their pixels first or it was missed in the coding for the CreateImage() routine.

Correct working code for this program can be found HERE.


Derron(Posted 2016) [#2]
You could do

img:Timage=CreateImage(x,y)
LockImage(img).ClearPixels(0)


why?
CreateImage just creates everything to get a "image" - it does not know the content or so. And why should it clear everything (needs CPU cycles) if you do something else with it (eg pasting a pixmaps content to it).


bye
Ron


dw817(Posted 2016) [#3]
Yep we were checking this on a different page. I can use ClearPixels() w LockImage(). It could be configurable, however.

Function CreateImage:Timage(x,y,f=0)

Where:
f=0 default, only create
f=1 create transparent
f=2 create black
f=3 create white

Don't the people who wrote BlitzMAX even think of these things ? :)


Casaber(Posted 2016) [#4]
An even better solution would've been to make f into a simple RRGGBBAA integer, which became the default pixel filled.


dw817(Posted 2016) [#5]
I like that, Casaber ! That's a good idea. Well ... I know there is a forum in here where people are tossing back and forth ideas of modifying the original system.

http://www.blitzbasic.com/Community/topics.php?forum=110

Maybe they would go for that. Hmm ... There isn't a FillPixels() routine, is there ?


Midimaster(Posted 2016) [#6]
use LockImage(img).ClearPixels(0) with a value <> 0 and it works like a "FillPixels()". That was what I want to tell you here:

http://www.blitzbasic.com/Account/showuser.php?id=10365

and Derron here:

http://www.blitzbasic.com/Account/showuser.php?id=8198