![]() |
|
|||||||
| Developers' Corner General World Wind development. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Super Member
Join Date: Jan 2006
Location: Eden, Utah
Posts: 1,779
![]() |
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 |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Feb 2008
Posts: 162
![]() |
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? |
|
|
|
|
|
#3 |
|
Super Member
Join Date: Jan 2006
Location: Eden, Utah
Posts: 1,779
![]() |
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 |
|
|
|
|
|
#4 |
|
Super Member
Join Date: Jan 2006
Location: Eden, Utah
Posts: 1,779
![]() |
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 Last edited by James_In_Utah; 03-27-2008 at 12:52 PM. |
|
|
|
|
|
#5 |
|
Super Member
Join Date: Jan 2006
Location: Eden, Utah
Posts: 1,779
![]() |
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 |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Feb 2008
Posts: 162
![]() |
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.
|
|
|
|
|
|
#7 |
|
Super Member
Join Date: Jan 2006
Location: Eden, Utah
Posts: 1,779
![]() |
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 |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Feb 2008
Posts: 162
![]() |
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.
|
|
|
|
|
|
#9 |
|
Super Member
Join Date: Jan 2006
Location: Eden, Utah
Posts: 1,779
![]() |
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 |
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Feb 2008
Posts: 162
![]() |
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.
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |