Displaying pixel-perfect images without blur when zooming

Jim Graham james.graham at oracle.com
Tue Aug 26 23:35:14 UTC 2014


We simply haven't implemented this yet:

https://javafx-jira.kenai.com/browse/RT-28629

			...jim

On 8/26/14 3:29 PM, Felipe Heidrich wrote:
>
>>
>> I'm curious. Why setSmooth doesn't work?
>>
>
> I tried setSmooth but it doesn’t work.
> See the doc: "Indicates whether to use a better quality filtering algorithm or a faster”.
> I expected this be a set for the interpolation algorithm (bilinear, bicubic, nearest neighbor, etc).
> My case I didn’t want a faster filter, I wanted no filter.
> Anyway, looking at the code, at the rendering level, NSImageView:
>      // RT-18701: this method does nothing
>      public void setSmooth(boolean s) {}
>
>
>> Also, do I really need to create an image in memory just to render something showing the pixels?
>>
>
> For a workaround done outside JavaFX I can’t think of any other way.
> I used this code snippet for a simple testing app, small images.
>
> Felipe
>
>
>
>> On Aug 27, 2014 3:32 AM, "Nico Krebs | www.mensch-und-maschine.de <http://www.mensch-und-maschine.de/>" <nicokrebs.dev at googlemail.com <mailto:nicokrebs.dev at googlemail.com>> wrote:
>> Thanx for that quick response!
>>
>> It is the right direction, but doing this for one image is not enough.
>> when having multiple images, the distances between them must be scaled,
>> too.
>>
>> I will extend your example to scale all nodes and their positions, too.
>> I try it tomorrow and post the result here.
>>
>> Nico
>>
>>> Felipe Heidrich <mailto:felipe.heidrich at oracle.com <mailto:felipe.heidrich at oracle.com>>
>>> 26. August 2014 19:20
>>>
>>> Hi Nico,
>>>
>>> Is this what you looking for:
>>>
>>> Image image - the image to scale up
>>>          int width = (int)image.getWidth();
>>>          int height = (int)image.getHeight();
>>>
>>> int z = (int)getZoom();  // 2, 4, 8, 16 (I only tested for powers of two)
>>>          IntBuffer src = IntBuffer.allocate(width * height);
>>>          WritablePixelFormat<IntBuffer> pf =
>>> PixelFormat.getIntArgbInstance();
>>>          image.getPixelReader().getPixels(0, 0, width, height, pf, src,
>>> width);
>>>          int newWidth = width * z;
>>>          int newHeight = height * z;
>>>          int[] dst = new int[newWidth * newHeight];
>>>          int index = 0;
>>>          for (int y = 0; y < height; y++) {
>>>              index = y * newWidth * z;
>>>              for (int x = 0; x < width; x++) {
>>>                  int pixel = src.get();
>>>                  for (int i = 0; i < z; i++) {
>>>                       for (int j = 0; j < z; j++) {
>>>                          dst[index + i + (newWidth * j)] = pixel;
>>>                       }
>>>                   }
>>>                   index += z;
>>>              }
>>>           }
>>>           WritableImage bigImage = new WritableImage(newWidth, newHeight);
>>>           bigImage.getPixelWriter().setPixels(0, 0, newWidth,
>>> newHeight, pf, dst, 0, newWidth);
>>>           preview.setImage(bigImage);
>>>           preview.setFitWidth(newWidth);
>>>
>>>
>>> preview is ImageView where the scale up image is displayed.
>>>
>>>
>>> Felipe
>>>
>>>
>>>
>>
>> --
>> Nico Krebs
>>
>> Michelangelostraße 1
>> 01217 Dresden
>>
>> web:     www.mensch-und-maschine.de <http://www.mensch-und-maschine.de/>
>> mobil:    0162 / 85 89 667
>> mail:    nicokrebs.dev at googlemail.com <mailto:nicokrebs.dev at googlemail.com>
>> skype:    k-dottus
>> icq:    324 143 104
>> fax:    032 12 - 11 39 77 6
>> twitter: nico_krebs
>


More information about the openjfx-dev mailing list