Peculiar SVG transparency issue


#1

I have several SVG icons I use for cursors my JUCE applications.  All but one of them have worked perfectly for over a year.  One of them for no reason I can see looks fine in all the SVG editors I have access to but when I use it as a JUCE cursor, the transparent areas are covered with multicolored fuzz.

I managed to edit it down into a tiny file that looks fine in a browser or an editor but is total hash on Juce when used as a cursor - which I attached.  I also used it to replace one of my non-cursor icons - that looks fine too.

This has been happening for many versions of Juce.  I just updated to 3.0 but no change...

Any ideas?


#2

Seems like a really simple file.. What code are you using to convert it to an Image?


#3

Just instrumented the code to make sure.

I'm using Drawable::createFromImageData.  I checked to make sure that the length and data was correct.  I use this method elsewhere with apparently good effects...

I'm testing on OS/X 10.8.


#4

More specific details:

  juce::Image img(
      juce::Image::ARGB, ZOOM_CURSOR_WIDTH, ZOOM_CURSOR_HEIGHT, false);
  Graphics g(img);
  ptr<Drawable> drawable(BINARY_DATA(ZoomInCursor_svg, Drawable));
  drawable->draw(g, 1.0f);
  return img;

BINARY_DATA wraps Drawable::createFromImageData.

I wrote this a long time ago... but it was working initially (IIRC) and hasn't been changed.

 


#5

When you create your image, you're passing 'false' as the last parameter, which tells it not to bother clearing the image - that means you could be drawing on top of garbage.. Maybe you've just been lucky with your other cursors that they happened to allocate empty blocks of memory!


#6

Good catch, but that didn't entirely fix it.  (I note you've been replacing all those booleans with enums, for no doubt exactly this reason).

Now the cursor is entirely non-existent!

At this point, this is the only custom cursor I have in the program, so I'm now suspecting some error on that codepath.  I'll examine it tonight (as I now have a full-time job, woo!)