Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » strange transform error(SWT Transform Pixel Shift Error)
strange transform error [message #635992] Thu, 28 October 2010 20:44 Go to next message
rhtcguru  is currently offline rhtcguru Friend
Messages: 2
Registered: October 2010
Junior Member
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 20:45]

Report message to a moderator

Re: strange transform error [message #636125 is a reply to message #635992] Fri, 29 October 2010 12:17 Go to previous message
Lakshmi ShanmugamFriend
Messages: 275
Registered: July 2009
Location: India
Senior Member
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?


Lakshmi P Shanmugam
Previous Topic:Table & Tableviewer column pack
Next Topic:GroupLayout or FormLayout?
Goto Forum:
  


Current Time: Wed Dec 13 07:28:21 GMT 2017

Powered by FUDForum. Page generated in 0.01626 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software