Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pan of ImageViewer is saved in internal state and exposed via getCroppedImage() #3804

Open
shai-almog opened this issue Apr 18, 2024 · 0 comments
Assignees

Comments

@shai-almog
Copy link
Collaborator

When panning an ImageViewer the image doesn't move in the UI but the pan does change the image state. As a result the getCroppedImage() results suddenly become "flaky". This is discussed here.

I created the following test case:

Form hi = new Form("Crop", new GridLayout(2, 1));
hi.setScrollable(false);
Image greenImage = Image.createImage(400, 400, 0xff00ff00);
Graphics g = greenImage.getGraphics();
g.setColor(0xffffff);
g.drawLine(0, 0, 400, 400);
g.drawLine(400, 0, 0, 400);
final ImageViewer iv = new ImageViewer(greenImage);
Style ivStyle = iv.getAllStyles();
ivStyle.setBgTransparency(255);
ivStyle.setBgColor(0xff);
Label cropPreview = new Label();
hi.addAll(iv, cropPreview);
hi.show();
UITimer.timer(1000, true, () -> {
    cropPreview.setIcon(iv.getCroppedImage(0xff0000));
});

The first screenshot shows the default state which seems correct to me, the second screenshot shows a zoom and left pan. Notice that the pan is rendered to the screenshot but ignored by the image viewer. To zoom in the simulator switch out of single window mode and ctrl-right mouse button drag from top left to bottom right.

CodenameOne Screenshot 1

CodenameOne Screenshot 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants