2 Replies Latest reply on Apr 13, 2007 8:50 PM by Marcus_House

    Flash not reading colour correctfrom an external PNG? Bug? Or am I missing something?

    Marcus_House
      Hi guys and gals.
      I have a very interesting bug I think.. Wondering if there is a way around the problem I'm having.

      ok.. Very Very simply script here..

      Make new flash movie..
      On frame one.. put this code.

      r=this.createEmptyMovieClip('currentImageMask',this.getNextHighestDepth());
      r.loadMovie('test.png');

      (because I'm lazy and didnt put in loading detection... on frame 20 put this code.

      import flash.display.BitmapData;
      image_bitmap = new flash.display.BitmapData(r._width, r._height,false);
      image_bitmap.draw(r);
      curr_colour = this.image_bitmap.getPixel(5, 5); //0
      trace(curr_colour.toString(16));
      stop();

      Now... make a simple image with the rgb colour 100,100,100 filled in it. (Mine is a simple 50x50 pixel image filled with that colour. save the png as "test.png" and put next to the fla with code above. You will see that the colour returned in the trace is not the hex value that matches color 100,100,100... it matches 99,99,99. Flash isnt reading the colour correctly...

      Now this same test returns the correct color and works fine if using a .gif or a .jpg. but I cannot do what I want with these formats. it must be a png.. .it must read the rgb value 100% correct every time and the image MUST be loaded from an external file.

      It seems that regardless the rgb is off by one. so if colour was 25,25,25 it would be returned as 24,24,24
      Is there any other way to do what I need to do.. or is there a bug in my code.. please anyone help.. I'm pulling my hair out with what should be a simple damn thing to do.