fyi: i just checked if the scrollpane is smoothing the images, but it`s not. removing the scrollpane keeps images smoothed.
> Edu García <mailto:[email protected]> > 26. August 2014 23:13 > > I'm curious. Why setSmooth doesn't work? > > Also, do I really need to create an image in memory just to render > something showing the pixels? > > Nico Krebs | www.mensch-und-maschine.de > <mailto:[email protected]> > 26. August 2014 19:31 > 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:[email protected]> > 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 | www.mensch-und-maschine.de > <mailto:[email protected]> > 26. August 2014 19:00 > Hi there, > > i want to display multiple images (layers) inside a scene and want to be > able to zoom without having "blurry" images as you can see in the images > in the attachment (on the left you can see very big scaled pixels as i > need it and on the right is the "blurry" JavaFX-Result on which i cannot > identify single pixels. > > i used the zoom pane example from > https://stackoverflow.com/questions/16680295/javafx-correct-scaling > > this is how i initialize my scene: > > ArrayList<ImageView> listOfImageViews = getImageViews(); > //imageviews are created from bufferedimages with: > SwingFXUtils.toFXImage(image, null) > final Group layerGroup = new Group(listOfImageViews); > this.stackPane = new StackPane(); > stackPane.getChildren().add(layerGroup); > scene = new Scene(stackPane); > this.stackPane.getChildren().add(this.scrollPane); > > this.stackPane.getChildren().add(scrollPane.createZoomPane(listOfImageViews > )); > this.setScene(scene); > > and this is how zooming is done: > > ...//calculate scalefactor from scrolling > ... > layerGroup .setScaleX(layerGroup .getScaleX() * scaleFactor); > layerGroup .setScaleY(layerGroup .getScaleY() * scaleFactor); > ... > > when i zoom in so that i theoreticallly could see single pixels, all i > see is a blurry area. (see examples) > i know already that that`s JavaFX default behaviour and even if i set > setSmooth(false), the antialiasing or precision errors or whatever is > causing this, persists. > > is there perhaps another way? i am even willing to write my own > implementation of Imageview if it would help. > > Can anybody please help me out? > > if you need more details, please ask :) > > thanks in advance and greetz, > Nico > -- Nico Krebs Michelangelostraße 1 01217 Dresden web: www.mensch-und-maschine.de mobil: 0162 / 85 89 667 mail: [email protected] skype: k-dottus icq: 324 143 104 fax: 032 12 - 11 39 77 6 twitter: nico_krebs
