[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Creating custom cursor on Linux GTK
|
- From: Alex Molochnikov <alexm@xxxxxxx>
- Date: Thu, 26 Jun 2008 10:31:15 -0600
- Newsgroups: eclipse.platform.swt
- Organization: Kelman Technologies Inc.
- User-agent: Thunderbird 2.0.0.14 (Windows/20080421)
To Linux/GTK gurus:
I am trying to create a custom cursor from an image built dynamically by
the app. The image is actually a resizing (double-pointed arrow) icon
rotated by an angle that is driven by the user data, so it has to be
made on the fly.
I put together the following code:
ImageData imageData = <get from a file with standard (unrotated) icon>
int size = Math.max(imageData.width, imageData.height);
int midPoint = size / 2;
Image originalImage = new Image(drawingView.getDisplay(), imageData);
Image transformedImage = new Image(drawingView.getDisplay(), size,size);
GC g = new GC(transformedImage);
Transform tr = new Transform(g.getDevice());
tr.translate(midPoint, midPoint);
tr.rotate(angle);
tr.translate(-midPoint, -midPoint);
g.setTransform(tr);
g.drawImage(originalImage, midPoint - imageData.width / 2, midPoint -
imageData.height / 2);
arrowCursor = new Cursor(drawingView.getDisplay(),
transformedImage.getImageData(), midPoint, midPoint);
drawingView.setCursor(arrowCursor);
showArrowCursor = true;
tr.dispose();
g.dispose();
originalImage.dispose();
transformedImage.dispose();
There I take an image from the file, and draw it into an off-screen
image buffer, with the rotated transform, then set the new cursor on SWT
Composite.
This works fine on Windows. However, on Linux (GTK) the cursor never
shows. If the same cursor is produced from an unadulterated image that
comes straight from the file, it shows. If I make a copy of that same
image into an off-screen buffer, even without any transform applied, the
cursor disappears.
There must be something in the way the new image is created (color
depth?) that prevents it from being displayed in the cursor.
Any ideas what is wrong here?
Thanks,
Alex Molochnikov
Kelman Technologies Inc.