Blurry images with drawImage and drawImageAt, why?


#1

I want to draw a image exactly as is, but drawImage and drawImageAt somehow modifies the original image  

Is there any way to draw images without apply blur or antialiasing? 

I'ts happens on osx, I still have not tried the other OS.

Image mage = ImageFileFormat::loadFrom (BinaryData::vustrip_png, BinaryData::vustrip_pngSize);
g.drawImageAt(mage, 0, 0);

In the screenshot, left: original image, right: image drawed in juce plugin.

http://oi58.tinypic.com/miyu1g.jpg


#2

Maybe you're misinterpreting a non-integer scale factor or sub-pixel offset as a "blur"?

Although your code is drawing the image at (0, 0), perhaps an affine transform has been applied to the Component or Graphics object when you're drawing it.


#3

I also noticed a light blur when painting non-retina images on retina screens (but very minor noticeable) (when using a non-retina screen, the picture is exact, so its not a subpixel/positioning issue). Maybe just OSX oversampling algorithm adds a bit blur, but decouple alaising effects depending on position ... 


#4

I don't know what I'm doing wrong, all coords are integers, I'm not applying scaling, blur, oversampling, etc... I'm only want to draw a raw image without any effect.

It may be something related to retina? there are any way to fix it? or am I doing something wrong?


#5

Try not using the core image loader.


#6

As Joel says, try not using the core image loader to see if that's doing anything to the image.

 

It's also worth remembering however that if you have an image with a logical pixel size (i.e. the pixels you use to set windows sizes and position Components etc.) and then draw it on a retina screen it will be up-sampled to fit in the (now double) physical number of pixels.

To get a pixel-for-pixel replication you'll need to provide 2x images for all of your resources and make sure you use the correct one depending on the physical pixel scale factor it is being drawn on to.


#7

I disabled core graphics, but the same thing happens, 

Anyway, with 2x scaled images, and then drawing these scaled to 0.5 looks great on retina, I think the best will be doing two image repositories, is there any way to detect retina?


#8

Ok, I found 
Desktop::getInstance().getDisplays().getMainDisplay().scale but It returns 1 in my macbook with retina,  i'll keep looking at the documentation.