image question

BlitzMax Forums/BlitzMax Beginners Area/image question

Cruis.In(Posted 2006) [#1]
hey, I have ships which are drawn on a black back ground. 2d ships of course. top down view.

if i had one on a blue background, is there someway i can mask the blue, that it doesn't show up when in game, and hence the ship image isn't read as being from the border of this blue?

also does magic pink still work?


H&K(Posted 2006) [#2]
Function SetMaskColor( red,green,blue )
Description Set current mask color.
Information The current mask color is used to build an alpha mask when images are loaded or modified. The red, green and blue parameters should be in the range of 0 to 255.

Just make sure you have alpha mask set, and that you set the mask colour before you load the image. (well the before load thing isnt compulsory (ish), but it makes things a hell of a lot easyer)


Cruis.In(Posted 2006) [#3]
before I load it? or before I draw it?

so for this one image of the background is blue, i can setmaskcolor(code to blue) then draw it? or load it with it masked already. Just wondering if you meant draw instead of load.


tonyg(Posted 2006) [#4]
errrr.. which of those two options have you tried?
The current mask color is used to build an alpha mask when images are loaded or modified

I would guess 'before' you load but don't take my word for it.


H&K(Posted 2006) [#5]
Did I not post "...set the mask colour before you load the image..."


Cruis.In(Posted 2006) [#6]
could be a typo :)


Cruis.In(Posted 2006) [#7]
so then I cant have more than one mask color, its either black blue pink yellow or green or whatever


H&K(Posted 2006) [#8]
No, you can then change it for the next image you load. What it is doing is building an alpha mask, so you tell it that its green, load the image it builds the mask with green as the mask colour, then you tell it the mask colour is cyan, and it loads the next image and builds the mask with the colour cyan etc

What I tend to do is load the image as a pixmap, find the colour of the top left pixel, kill the pixmap, set the mask colour to the colour I just found, then load the image back in as an image. (I dont really do this, but that explains it easyer)


Cruis.In(Posted 2006) [#9]
so if i set the mask before i load one drawing, it doesn't set it for the rest, that are way after? reason i ask is all my images are globals in globals.bmx which is included in my main. when i want to add graphics or sound, i just add a global newsound = loadsound blah blah


Dreamora(Posted 2006) [#10]
Anything you set within BM holds until it is set to something different, so its fully up to you to decide when you need to have it a different value for the next operation you are doing :-)


H&K(Posted 2006) [#11]
P1) How do I do this
R1) You set this before you load an image
P2) Before I Draw the Image or before I load the Image
R2) Before you load the Image
P3) So I can only Set it once
R3) No you can set it before you load any image, and reset it before you load another image
P3) So I have to set it before I load every image
R3) Ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

In case you didnt realise this is just cut from the docs
Function SetMaskColor( red,green,blue )
Description Set current mask color.
Information The current mask color is used to build an alpha mask when images are loaded or modified. The red, green and blue parameters should be in the range of 0 to 255.


So, when you load (or modify) an image, Bmax builds an Alpha mask for that image, with the current mask color. If you want the Mask colour to be a different mask colour you change it. If you dont want the mask colour to be a different colour you dont change it


kenshin(Posted 2006) [#12]
lol, are you sure about this? Can't I just set the alpha after I turn my computer off?


Justus(Posted 2006) [#13]
Before you _load_ an image, which means: as you are creating it in your painting software, you should add a socalled Alphachannel to your picture in order to "paint with transparency". So you specify the (half-)transparent parts of your picture already in your image programme.

I would recommend GIMP or Photoshop. Save it as a png file and be happy with it.


Dreamora(Posted 2006) [#14]
Or use Pixia. Small easy app that supports this kind of stuff extremely well.


Tom Darby(Posted 2006) [#15]
To echo Justus: if you save images as PNG with proper alpha channels, you won't need to worry about this at all...


Cruis.In(Posted 2006) [#16]
so if I save a ship with a blue alpha channel, and one with a black one, when they loadimage in blitzmax, they are fine. true?

thanks alot guys! im not artist after all...


H&K(Posted 2006) [#17]
no.
Unless you tell the program to change the alpha channal to blue for the blue one, then load it in, then change it to black for the black one then load it in. THEN they are ok. If you save them with an alpha channel (which isnt a colour so dont go saying what colour it used to be) they will be ok, otherwise you have to change the alpha mask colour to the colour you wnat masked each time you load the image. But once the images are loaded the have an alpha channel SO IT DOESNT MATTER what colour it used to be, cos NOW its an alpha layer


Cruis.In(Posted 2006) [#18]
save all with one channel.


H&K(Posted 2006) [#19]
What?
Look if you have made the images, just change the mask colour to the colour you ued for the background, and load them in. Then change the mask colour if you have some that you made with a different colour


TomToad(Posted 2006) [#20]
SetMaskColor 0,0,0 'Set Mask to Black
ImageWithBlackMask:TImage = LoadImage("MyImageWithABlackMask.png")
SetMaskColor 0,0,255 'Set Mask To Blue
ImageWithBlueMask:TImage = LoadImage("MyImageWithABlueMask.png")

Repeat
 DrawImage ImageWithBlackMask,10,10 'Both Images will be drawn correctly.
 DrawImage ImageWithBlueMask,100,100
 Flip
Until GameDone