Thanks for the reply Alex,
I'm not loading it in two different ways. I'm just loading the image using 
loader as you see in 'loadImageAsBitmap' method and comparing the color 
information of the pixels with original image.

--- In flexcoders@yahoogroups.com, Alex Harui <aharui@...> wrote:
>
> I'm missing what the other way of loading is and how you are getting its 
> pixels.
> 
> 
> On 8/27/12 3:15 AM, "RAJ" <raaj_ece@...> wrote:
> 
> 
> 
> 
> 
> 
> Hi all ,
> 
> My aim is to load two images and compare its color information pixel by 
> pixel. For this purpose i used "flash.display.Loader" class to load the 
> images, and once load completes i'll typecast the loaded content to bitmap 
> object (loaderObj.content as Bitmap). Finally i'll get the bitmapdata from 
> the bitmap of both the images and compare the pixels.
> 
> Now the problem is the color information of the original image and the loaded 
> bitmap is slightly different. For example the color value of pixels of the 
> attached image image1.jpg is 0xDDDDDD for complete 1366x768. And for the same 
> image when it is loaded as bitmap the color value of pixels are different 
> from the original value (For some pixels only, not all pixels are different).
> 
> I've given the source code below.
> 
> Please can anyone help me out how to resolve this issue?
> 
> <?xml version="1.0" encoding="utf-8"?>
> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009 
> <http://ns.adobe.com/mxml/2009> "
>                                                      
> xmlns:s="library://ns.adobe.com/flex/spark"
>                                                      
> xmlns:mx="library://ns.adobe.com/flex/mx"
>    ! ;                                                  width="1376" 
> height="800"
>                                                      showStatusBar="false">
> 
>          <fx:Declarations>
>                     <!-- Place non-visual elements (e.g., services, value 
> objects) here -->
>           </fx:Declarations>
> 
>          <fx:Script>
>                     <![CDATA[
>                               private function loadBtn_ClickHandler():void{
>                                         var file:File = new 
> File(File.desktopDirectory.nativePath);
>                                       &nbs! p; 
> file.addEventListener(Event.SELECT, onFileSelectionHandler);
>                                         file.browseForOpen("Open an 
> image",[new FileFilter("Images", "*.jpg;*.gif;*.png;*.jpeg")]);
>                               }
> 
>                              private function 
> onFileSelectionHandler(ev:Event):void{
>                                         var loadedFilePath:String = 
> (ev.target as File).nativePath;
>                                         loadImageAsBitmap(loadedFilePath);
>                           !     }
> 
>                              /* Load image as bitmap using Loader */
>                               private function 
> loadImageAsBitmap(url:String):void 
> <http://tech.groups.yahoo.com/group/flexcoders/String):void> {
>                                         var loader:Loader = new Loader();
>                  &! nbsp;                      // load content as bitmap
>                                         
> loader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
> onContentLoadComplete);
>                                         
> loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, 
> onContentLoadFail);
>                               &nbs! p;         loader.load! (new URL 
> Request(url));
>                               }
> 
>                              private function 
> onContentLoadComplete(ev:Event):void{
>                                         var loaderInfo:LoaderInfo = ev.target 
> as LoaderInfo;
>                                         var bitmap:Bitmap = 
> loaderInfo.content as Bitmap;
>                          ! ;               printPixelValue(bitmap.bitmapData);
>                                         container_ID.addChild(bitmap);
>                               }
> 
>                              private function 
> onContentLoadFail(ioe:IOErrorEvent):void{
>                                         trace("Image Load Failed");
>                               }
> 
>                              private function 
> printPixelValue(bmData:BitmapData):void{
>                                         var initPixelValue:Number = -1;
>                                         //for (var countI:int = 0; countI < 
> bmData.height; countI++) {
>                         &nb! sp;               var countI:int = 1;
>                                         for (var countJ:int = 0; countJ < 
> bmData.width; countJ++) {
>                                                   var pixelValue:Number = 
> bmData.getPixel32(countJ, countI);
>                                     ! ;          &! nbsp;&nb sp;  
> if(pixelValue != initPixelValue){
>                                                             initPixelValue = 
> pixelValue;
>                                                             // Print the 
> pixel value only for one row
>                           ! ;                                  trace("Pixel 
> Value at " + countI + "x" + countJ + " is: " + pixelValue);
>                                                   }
>                                         }
>                             &nbs! p;          ! trace(" Pixel Value at " + 
> countI + "x" + countJ + " is: " + pixelValue);
>                                         //}
>                               }
>                     ]]>
>           </fx:Script>
> 
>           <s:Button id="loadBtn_ID" label="Load!" 
> click="loadBtn_ClickHandler()"
>                        &nb! sp;        x="5" y="5" height="20"/>
>           <mx:UIComponent id="container_ID" x="5" y="30" width="1366" 
> height="768"/>
> </s:WindowedApplication>
> 
> 
> 
> Regards,
> Rajkumar S
> 
> 
> 
> 
> 
> --
> Alex Harui
> Flex SDK Team
> Adobe Systems, Inc.
> http://blogs.adobe.com/aharui
>

Reply via email to