Displaying pixel-perfect images without blur when zooming

Nico Krebs | www.mensch-und-maschine.de nicokrebs.dev at googlemail.com
Tue Aug 26 17:31:43 UTC 2014


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>
> 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
mobil:    0162 / 85 89 667
mail:    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