strange transform error [message #635992] |
Thu, 28 October 2010 16:44  |
Eclipse User |
|
|
|
I've got this really annoying Transform artifact showing up in my graphical routines. I traced it down to a transform error. What happens is that drawing routines that are translated past horizontal pixel 255 get shifted by one pixel to the left. So, a line translated to 256 will draw at 255. 257 will draw at 256, etc. Same thing happens on verticle but at different value. I wrote a very simple code snippet to illustrate this problem. Two lines should be drawn with 1 pixel between them. However, the 2nd line translated to 257 wil draw at 256 which will be right next to the first line drawn at 255. Anyone know what the deal is with this?
import org.eclipse.swt.*;
public class MainClass {
public static void main(String[] args){
Display display = new Display();
Shell shell = new Shell(display);
shell.open();
Canvas canvas = new Canvas(shell, SWT.NO_BACKGROUND);
canvas.setBounds(0,0,640,480);
GC gc = new GC(canvas);
Transform t1 = new Transform(gc.getDevice());
t1.translate(255,0);
gc.setTranform(t1);
gc.drawLine(0,0,0,100);
t1.translate(2,0);
gc.setTransform(t1);
gc.drawLine(0,0,0,100);
t1.dispose();
gc.dispose();
while( !shell.isDisposed()){
if(!display.readAndDispatch()){
display.sleep();
}
}
canvas.dispose();
shell.dispose();
display.dispose();
}
[Updated on: Thu, 28 October 2010 16:45] by Moderator
|
|
|
Re: strange transform error [message #636125 is a reply to message #635992] |
Fri, 29 October 2010 08:17  |
Eclipse User |
|
|
|
Hi,
I ran your example snippet on my windows xp machine and it worked fine for me. The lines are drawn correctly at 255 and 257 with a gap between them. Which version of SWT/eclipse are you using. Also on which platform do you see this problem?
|
|
|
Powered by
FUDForum. Page generated in 0.07826 seconds