|
Author |
Topic: stretching: viewsize(width,height) (Read 1419 times) |
|
cello
|
stretching: viewsize(width,height)
« on: Sep 21st, 2004, 4:54pm » |
|
I would like to put forth a feature suggestion. Basically the idea here is to separate the 1-to-1 mapping of pixel to screen space. This has a number of applications such as sizing applets 2x to reduce the calculations yet increase the view size at detail loss. It works the other way so that images of higher than the screen resolution can be scaled down to a viewable size for preview. edit: sorry hit post by mistake... Code: public int viewwidth,viewheight; protected boolean viewstretching = false; public void viewsize(int width, int height) { this.viewwidth = width; this.viewwheight = height; viewstretching = this.width != width || this.height != height; update(); } public void paint(Graphics g1) { g.mis.newPixels(pixels, g.cm, 0, width); if (g != null) { if (stretching) g1.drawImage(g.image, 0, 0, viewwidth, viewheight, null); else g1.drawImage(g.image, 0, 0, null); } } // then in applicable mouse methods: qmouseX = mouseevent.getX(); qmouseY = mouseevent.getY(); if (viewstretching) { qmouseX = qmouseX * width / viewwidth; qmouseY = qmouseY * height / viewheight; } |
| I think that's it. Additionally it might be nice to autoset the view size to the applet size so you can scale programs by simply chaning the applet size. I'm not sure if that's something you want by default or not. Marcello
|
« Last Edit: Sep 21st, 2004, 4:57pm by cello » |
|
|
|
|
fry
|
Re: stretching: viewsize(width,height)
« Reply #1 on: Sep 21st, 2004, 9:04pm » |
|
this will probably be possible with the new rendering setup, though i'm not sure if it'll be in 70 or after that. we'll have to make this sort of separation for exporting out large, high-res postscript images, for instance, so i think we'll be able to do the same sort of thing as you're suggesting.
|
|
|
|
|