1 Reply Latest reply on Jul 1, 2011 1:06 PM by William Spence

    Color Shifts when manipulating images

    William Spence Level 1

      I am taking images from cameras in the sRGB color space and converting them into thumbnails in AIR.  The user is then able to rotate the photos to the proper orientation if needed.  This is accomplished by manipulating bitmapdata using matrices.  During testing, I noticed that if I rotated images 8 or 9 times, there was a clear shift in the colors that was occuring towards green.  I was wondering if there are things that can be done to avoid this?  Here is some of the code used to rotate the images.

       

       

           var rotBM:Bitmap = Bitmap(event.currentTarget.content);
           
           // Calculate rotation and offsets
           var radians:Number = 90 * (Math.PI / 180.0);
           var offsetWidth:Number = 70/2.0;
           var offsetHeight:Number =  70/2.0;
           
           // Perform rotation
           var matrix:Matrix = new Matrix();
           matrix.translate(-1*offsetWidth, -1*offsetHeight);
           matrix.rotate(radians);
           matrix.translate(offsetHeight, offsetWidth);
           
           //get BitmapData          
           var rotBitmapData:BitmapData = new BitmapData(70, 70);
           rotBitmapData.draw(rotBM, matrix);
      

       

       

      I know that in the draw() method of the BitmapData class, that there are parameters that deal with color transforms but I do not know if that would help here.  Does anyone with experience with color transforms and manipulating images know how to ensure that I stay within the sRGB colorspace or why I might be seeing this color shift?

       

      Thanks