PDA

View Full Version : ctlimage() transmask



nickdigital
04-23-2012, 04:52 PM
How does one use the transmask value in ctlimage()?
ctlimage(imageName, xOffset, yOffset, transMask)

xchrisx
04-24-2012, 09:25 AM
Personally I havent yet had a chance to play with that, but isn't it a color that you wanted keyed out i.e. <0,255,0> (for green) ? At least that is my understanding from the docs:

The optional parameters are the image’s X (horizontal) offset, the image’s Y (vertical) offset, and a color transparency mask—as a single integer or a vector—for simple color filtering (which can, in some cases, greatly increase display speed).

nickdigital
04-24-2012, 09:44 AM
I'll check that out Chris. If your explanation is right I wish the docs would just say that...:D

nickdigital
04-24-2012, 11:06 AM
Yeah, the color info is to key a color out in your image. It's not very pretty though. I'm assuming that lscript can't read the transparency in a png file which is too bad.

xchrisx
04-24-2012, 11:11 AM
just out of curiosity have you tried a transparent TGA? it seems that Lscript prefers TGAs for most things.

nickdigital
04-24-2012, 11:23 AM
Ya, I tried a tga with an embedded alpha and it didn't cut the image out.

xchrisx
04-24-2012, 11:33 AM
That is unfortunate, but not surprising. :(

nickdigital
04-24-2012, 11:38 AM
Yeah. I was just adding a picture to my UI window. It's all cosmetic anyway...nothing really important. :hey:

sami
05-08-2012, 06:17 AM
Yeah. I was just adding a picture to my UI window. It's all cosmetic anyway...nothing really important. :hey:

Did you figure this out yet? I also have a couple of cosmetic icons etc that I'd like to work for the LW9 and LW11 interface background colors. I suppose I could always include both sets of images and show the right one depending on which LW version but that's lame - I'd rather have a transparent image with an alpha.

nickdigital
05-08-2012, 09:43 AM
Did you figure this out yet? I also have a couple of cosmetic icons etc that I'd like to work for the LW9 and LW11 interface background colors. I suppose I could always include both sets of images and show the right one depending on which LW version but that's lame - I'd rather have a transparent image with an alpha.

I wasn't able to figure out how to get a clean alpha. I put green behind my image and tried to key that out but lscript doesn't look to key that out very cleanly. There was a lot of green fringe pixels around the image.

sami
05-10-2012, 09:10 PM
Once constructed, the glyph can be drawn into display contexts using the new drawglyph() function. This function takes the Glyph Object Agent, along with the X and Y position within the context where the glyph should be drawn:

...

// draw the cursor glyph
drawglyph(cursor_img,
cursor_pos.x - integer(cursor_img.w / 2),
cursor_pos.y - integer(cursor_img.h / 2));
...

Two additional arguments, both optional, can be provided to the Glyph() constructor. By default, Glyphs are generated in a way that allows them to be drawn to the display context with the utmost speed. What is traded for such drawing speed is the ability to directly access individual pixels in the image. The second argument you can provide to the Glyph() constructor is a Boolean flag that tells LScript that you'll need pixel-based access to the image data in the Glyph (dual-mode). You'll need to specify this mode, for instance, when you plan to overlay the Glyph onto Image Filter data (Image Filter data is not a valid display context, so the high-speed form of the Glyph cannot be directly drawn onto it).

The third optional argument is a transparency color mask to be used when drawing the Glyph. Because the use of such a mask requires per-pixel access to the image data, specifying a transparency mask automatically enables this mode in the Glyph object.

I tried using Glyphs now and I can't get transparency on them either at all - despite Mike Green's note above despite trying all the variations of _png, _tga, & _psd.

So what I've resorted to is just having the different background colors saved in 2 different images for each glyph and dynamically load the correct one based on LW9 or LW11 -- since LW11 dialog colors are different.

Have you been able to get the single color transparency to work with Glyph() at all? I need to use that and not ctlimage() in some places.