World Wind Forums

Go Back   World Wind Forums > WorldWind .Net Development > Developers' Corner

Developers' Corner General World Wind development.

Reply
 
Thread Tools Display Modes
Old 03-27-2008, 12:49 AM   #1
James_In_Utah
Super Member
 
James_In_Utah's Avatar
 
Join Date: Jan 2006
Location: Eden, Utah
Posts: 1,779
James_In_Utah
Default How to shade an icon from KML Importer???

Hi,
We export KML from one of our applications. The KML specifies a placemark with an icon called Shaded_Icon.png. It is basically a grey blob. The placemark has a <style> and in that <style> tag there is an <iconstyle> tag. In that tag is a <color> tag with values such as "ffffff00". If I open the KML with GE I get a red icon. If I open the KML with WW, I get a grey blob. I debuged throug the kmlparser, and it is pulling the color out of the stye, and the style is passed to CreateIcon() in the KMLParser.CS. At this point, we loose it. We create a KMLIcon called ic, and call layer.Add(ic). I need to know what attribute on an icon would shade it to the color that is in style.LineStyle.color.color. I've looked through the attributes and don't see anything useful. Any help on this would be greatly appreciated!
Thanks,
James
James_In_Utah is offline   Reply With Quote
Old 03-27-2008, 01:10 AM   #2
mayra
Senior Member
 
Join Date: Feb 2008
Posts: 162
mayra is on a distinguished road
Default

As far as I am aware the icon class only supports displaying a bitmap, not a specific color. In order to get a red icon you need to provide an image file with a red icon in it.

Are you trying to provide a png, and then have some part of that png change color to that color? Or instead of using the png, to draw a circle of that color, or what?
mayra is offline   Reply With Quote
Old 03-27-2008, 02:27 AM   #3
James_In_Utah
Super Member
 
James_In_Utah's Avatar
 
Join Date: Jan 2006
Location: Eden, Utah
Posts: 1,779
James_In_Utah
Default

I'm not sure how they are doing it, but it works with GE. We have a grey icon and the KML specifies a color. The color changes. Sometimes it's red, sometimes blue, sometimes green, and sometimes something else. I've attached the .png. At one point in the KML Parser, when parsing the placemark, we actually read the style, and detect the color. Right before I add it to the layer, I could set an attribute to change the color, but I don't see a method that does that. I guess what I'm looking for is some sort of "fill" function that fills the icon with the detected color.
Thanks,
James


Name:  shaded_dot.png
Views: 1484
Size:  4.1 KB
James_In_Utah is offline   Reply With Quote
Old 03-27-2008, 05:51 AM   #4
James_In_Utah
Super Member
 
James_In_Utah's Avatar
 
Join Date: Jan 2006
Location: Eden, Utah
Posts: 1,779
James_In_Utah
Default

Actually I've attached the KML with the shaded_dot.png in case anyone would like to try this. I've also attached a screenshot of what the imported KML looks like in WW. I hard coded the extrude lines to be red in my code. By default they will be grey. If I open this KML with GE, some of the icons will be different colors, and a couple of the extrude lines will be the same color as the icons. There are a couple of changes needed in the KML Parser in order to match the view in GE more accurately.

1. If a <Linestyle><color> is specified, the extrude line should use that as the color. The current code doesn't seem to use it, but won't display the placemark if it isn't present. I added some logic to my copy to handle this not being present, but haven't set the color of the extrude line yet.

2. If <IconStyle><color> is specified, shade the icon with that color. If it is not specified, just draw the icon as is.



doc14.zip

Name:  screenshot_KML.jpg
Views: 1488
Size:  72.7 KB

Last edited by James_In_Utah; 03-27-2008 at 12:52 PM.
James_In_Utah is offline   Reply With Quote
Old 03-27-2008, 02:07 PM   #5
James_In_Utah
Super Member
 
James_In_Utah's Avatar
 
Join Date: Jan 2006
Location: Eden, Utah
Posts: 1,779
James_In_Utah
Default

OK,
So maybe the current Icon base class doesn't support shading or filling with a color. Is there an easy way to add this?
Thanks,
James
James_In_Utah is offline   Reply With Quote
Old 03-27-2008, 08:49 PM   #6
mayra
Senior Member
 
Join Date: Feb 2008
Posts: 162
mayra is on a distinguished road
Default

Quote:
Originally Posted by James_In_Utah View Post
OK,
So maybe the current Icon base class doesn't support shading or filling with a color. Is there an easy way to add this?
Thanks,
James
Not that I'm aware of. I'm still not sure exactly what you are trying to accomplish, but you either need to generate some directx code that will draw a circle/square that you can provide an arbitrary color to, or figure out some way to process your bitmap to add a little bit of the goal color to certain pixels or something. Really I think the easiest way at the moment would be to just create a bitmap that is what you want it to look like.
mayra is offline   Reply With Quote
Old 03-27-2008, 09:55 PM   #7
James_In_Utah
Super Member
 
James_In_Utah's Avatar
 
Join Date: Jan 2006
Location: Eden, Utah
Posts: 1,779
James_In_Utah
Default

The problem I have is that we currently have a process that spits out this KML. It always specifies this shaded_dot.png, and sets the color for that png using the <IconStyle><color> tag. Our folks currently use GE to load and work with these KMLs. I would like to switch them over to using WW. I can't alter the output of the KMLs, so I have to fix WW to read that color and shade the icon to match it.

I have tried using SetPixel on the KMLIcon that is created before passing it to layer.add(ic), but it seems slow, and doesn't actually line up with the icon yet. I'm still working on it. Any suggestions on how to modify the base class to have a SetColor() method that is passed either a System.Drawing.Color, or an ARGB value would be very much appreciated.
Thanks,
James
James_In_Utah is offline   Reply With Quote
Old 03-27-2008, 11:04 PM   #8
mayra
Senior Member
 
Join Date: Feb 2008
Posts: 162
mayra is on a distinguished road
Default

You have to define first what that set color would mean. Do you ignore the provided texture file and just draw a shape of that color, or do you shade some portion of the texture file that color, and if so how do you define what part.
mayra is offline   Reply With Quote
Old 03-27-2008, 11:19 PM   #9
James_In_Utah
Super Member
 
James_In_Utah's Avatar
 
Join Date: Jan 2006
Location: Eden, Utah
Posts: 1,779
James_In_Utah
Default

I'm going by what I see GE doing. It looks to me like they are completely wiping out all of texture except for the transparent portion. So my grey 64x64 png above needs to turn out to be a colored ball, not a colored square. The problem I have with the Setpixel function is that we scale that 64x64 png down to a 25x25 icon before adding it to the layer.
Thanks,
James
James_In_Utah is offline   Reply With Quote
Old 03-28-2008, 12:16 AM   #10
mayra
Senior Member
 
Join Date: Feb 2008
Posts: 162
mayra is on a distinguished road
Default

If that is the case it should be fairly simple to iterate through all of the pixels and set each non-transparent pixel to that color. However, it is a bit expensive. If you are doing a lot of icons you probably want some method for caching the bitmaps you have edited to reuse.
mayra is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
WW1.3.2-Plugin: Layer Edit canosso Add-ons & Scripts 21 02-27-2010 04:37 AM
Problems with KML Icon description Bubble James_In_Utah Developers' Corner 4 12-05-2007 07:00 PM
KML importer coloradokid Technical Support 15 03-18-2007 06:57 PM
KML Importer Question Unregistered Technical Support 6 01-12-2007 10:01 PM
KML importer not working r9c0x7 Add-ons & Scripts 5 11-01-2006 08:52 AM


All times are GMT +1. The time now is 09:39 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.