-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8u241, jfx14
-
x86
-
os_x
ADDITIONAL SYSTEM INFORMATION :
MacOSX 10.15.5, MacBook Pro 16, I7 2,6 GHz, 16GB Ram, AMD Radeon Pro 5300M 4 GB,
Intel UHD Graphics 630 1536 MB
Bug appears to be in:
Javafx Version: 14.0.1+1 (Gluon)
Java JDK Version: 14.0.1+7
as well as :
Javafx Version: 8.0.241-b07
Java Runtime Version: 1.8.0_241-b07
A DESCRIPTION OF THE PROBLEM :
Using an ImageView to display an image, the picture appears blurry.
Even "setPreservation" or "setCache" oes not help
REGRESSION : Last worked in version 14.0.1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. create an Image class and load a image into it
2. create an ImageView class and stuff the image into it
3. pass the imageView to a container (stackPane,pane, VBox, etc)
4. create a scene and pass the container into the scene
5. pass the scene into the primaryStage and run the program
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The image will be displayed sharply in the correct dimensions
ACTUAL -
The image appears blurry in the correct dimensions
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
System.out.println("Javafx Open JDK Version: " + System.getProperty("javafx.runtime.version"));
System.out.println("Java Open JDK Version: " + System.getProperty("java.runtime.version"));
ImageView imv = new ImageView();
Image image = new Image(getClass().getResourceAsStream("xcode.png"));
imv.setImage(image);
// imv.setPreserveRatio(true);
// imv.setSmooth(true);
// imv.setCache(true);
Pane root = new Pane();
root.setStyle("-fx-background-color: black;");
root.getChildren().add(imv);
Scene scene = new Scene(root);
primaryStage.setTitle("ImageView Blur");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
This is a workaround i found in StackOverFlow by Martin Sojka.
import com.sun.javafx.sg.prism.NGImageView;
import com.sun.javafx.sg.prism.NGNode;
import com.sun.prism.Graphics;
import com.sun.prism.Texture;
import com.sun.prism.impl.BaseResourceFactory;
import com.sun.prism.Image;
import javafx.scene.image.ImageView;
/**
* Modification of the JavaFx ImageView Class
* This subclass resolves a problem where the ImageView made images always blurry.
* Works on OSX and Windows 7/8/10
* @author Martin Sojka & Lappro
*/
@SuppressWarnings("restriction")
public class PixelatedImageView extends ImageView {
public PixelatedImageView(javafx.scene.image.Image image) {
super(image);
}
@Override
protected NGNode impl_createPeer() {
return new NGImageView() {
private Image image;
@Override
public void setImage(Object img) {
super.setImage(img);
image = (Image) img;
}
@Override
protected void renderContent(Graphics g) {
BaseResourceFactory factory = (BaseResourceFactory) g.getResourceFactory();
Texture tex = factory.getCachedTexture(image, Texture.WrapMode.CLAMP_TO_EDGE);
tex.setLinearFiltering(false);
tex.unlock();
super.renderContent(g);
}
};
}
}
FREQUENCY : always
MacOSX 10.15.5, MacBook Pro 16, I7 2,6 GHz, 16GB Ram, AMD Radeon Pro 5300M 4 GB,
Intel UHD Graphics 630 1536 MB
Bug appears to be in:
Javafx Version: 14.0.1+1 (Gluon)
Java JDK Version: 14.0.1+7
as well as :
Javafx Version: 8.0.241-b07
Java Runtime Version: 1.8.0_241-b07
A DESCRIPTION OF THE PROBLEM :
Using an ImageView to display an image, the picture appears blurry.
Even "setPreservation" or "setCache" oes not help
REGRESSION : Last worked in version 14.0.1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. create an Image class and load a image into it
2. create an ImageView class and stuff the image into it
3. pass the imageView to a container (stackPane,pane, VBox, etc)
4. create a scene and pass the container into the scene
5. pass the scene into the primaryStage and run the program
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The image will be displayed sharply in the correct dimensions
ACTUAL -
The image appears blurry in the correct dimensions
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
System.out.println("Javafx Open JDK Version: " + System.getProperty("javafx.runtime.version"));
System.out.println("Java Open JDK Version: " + System.getProperty("java.runtime.version"));
ImageView imv = new ImageView();
Image image = new Image(getClass().getResourceAsStream("xcode.png"));
imv.setImage(image);
// imv.setPreserveRatio(true);
// imv.setSmooth(true);
// imv.setCache(true);
Pane root = new Pane();
root.setStyle("-fx-background-color: black;");
root.getChildren().add(imv);
Scene scene = new Scene(root);
primaryStage.setTitle("ImageView Blur");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
This is a workaround i found in StackOverFlow by Martin Sojka.
import com.sun.javafx.sg.prism.NGImageView;
import com.sun.javafx.sg.prism.NGNode;
import com.sun.prism.Graphics;
import com.sun.prism.Texture;
import com.sun.prism.impl.BaseResourceFactory;
import com.sun.prism.Image;
import javafx.scene.image.ImageView;
/**
* Modification of the JavaFx ImageView Class
* This subclass resolves a problem where the ImageView made images always blurry.
* Works on OSX and Windows 7/8/10
* @author Martin Sojka & Lappro
*/
@SuppressWarnings("restriction")
public class PixelatedImageView extends ImageView {
public PixelatedImageView(javafx.scene.image.Image image) {
super(image);
}
@Override
protected NGNode impl_createPeer() {
return new NGImageView() {
private Image image;
@Override
public void setImage(Object img) {
super.setImage(img);
image = (Image) img;
}
@Override
protected void renderContent(Graphics g) {
BaseResourceFactory factory = (BaseResourceFactory) g.getResourceFactory();
Texture tex = factory.getCachedTexture(image, Texture.WrapMode.CLAMP_TO_EDGE);
tex.setLinearFiltering(false);
tex.unlock();
super.renderContent(g);
}
};
}
}
FREQUENCY : always
- duplicates
-
JDK-8211861 ImageView.setSmooth(false) does not work
-
- Open
-