PDA

View Full Version : Image transparency and view borders


jpan
04-15-2004, 08:29 AM
Hi,

A couple of questions:

1) I have a PNG image that has transparent background. However, when I load it into a view, the background shows up as black (which is the colour I specified to be transparent)... the same image in GIF will produce junk (as in, the image looks like static with colours)... I understand that GIF and PNG transparency is supported... so is there a problem with the way the images are created? I'm using Windows 2000...

2) If I wanted to create a view (with opacity=0.4 and bgcolor="blue") with blue borders, how can I go about doing that? The only thing I can think of is using four views to draw the lines in addition to the center view... which seems very naive. How can I accomplish this?

Thank you!

antun
04-15-2004, 09:48 AM
so is there a problem with the way the images are created?

Possibly - how are you creating the images? What software are you using? Maybe attach them to a post.


If I wanted to create a view (with opacity=0.4 and bgcolor="blue") with blue borders, how can I go about doing that?

You would use a bunch of views - one for the top line, one for the bottom line, and a view for the left line, right line and the center area. Stableborderlayout and constraints will help you there:


<canvas debug="true">
<view width="200" height="362" x="20" y="20">
<stableborderlayout axis="y" />
<view bgcolor="blue" height="5" width="${parent.width}" />
<view width="${parent.width}">
<stableborderlayout axis="x" />
<view bgcolor="blue" width="5" height="${parent.height}" />
<view height="${parent.height}" />
<view bgcolor="blue" width="5" height="${parent.height}" />
</view>
<view bgcolor="blue" height="5" width="${parent.width}" />
</view>
</canvas>


-Antun

jpan
04-15-2004, 11:27 AM
Thanks Antun! I ended up using a work-around, by converting the PNG file into SWF and that worked perfectly... so I think I'll just stick to it.

As for the borders, I'll do what you suggested! Was hoping that I didn't have to do that, but oh well...

One more question... I have a view that needs to set its resource to an image based on an XML...

<view resource="" width="20" height="20" datapath="MobileUnit">
<method event="ondata"><![CDATA[
var point = this.parent.parent.translate(this.datapath.xpathQu ery('lat/text()'), this.datapath.xpathQuery('long/text()'));
debug.write("icon="+this.datapath.xpathQuery('icon/text()'));
//this.setAttribute("resource", this.datapath.xpathQuery('icon/text()') );
this.setAttribute("resource", "img/truck-2.swf" );
this.setX( point.getX() );
this.setY( point.getY() );

]]></method>
</view>


Now, in the method ondata event, this.setAttribute("resource", "img/truck-2.swf") doesn't work, while putting the same string directly in the attribute for the view works. What am I missing??

Thank you!

antun
04-15-2004, 11:31 AM
Don't use setResource(); instead use setSource() - that's exactly what it's designed for.

-Antun