[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] SWT: Trying to create my own cursors.

I'm trying to create a custom cursor for one of my components.
I have a source image which doesn't contain a mask so I have to make
the mask manually in the source. I'm trying to do this as follows:

		RGB rgb[] = new RGB[2];
		rgb[0] = new RGB(0, 0, 0);
		rgb[1] = new RGB(255, 255, 255);
		PaletteData pd = new PaletteData(rgb);
		ImageData dat = new ImageData(20, 20, 1,pd);
		// Set pixels on 'dat' representing mask...
		dat.setPixel(3, 3, 1);
		...

I also have a normal Image object for the cursor itself. Then I do:

		Image img = ... original image...;
		Cursor curs = new Cursor(Display.getCurrent(),
			img.getImageData(), dat, 0, 0);

But I get the following exception:

	java.lang.IllegalArgumentException: Argument not valid
		at org.eclipse.swt.SWT.error(SWT.java:2103)
		at org.eclipse.swt.SWT.error(SWT.java:2049)
		at org.eclipse.swt.graphics.Cursor.<init>(Cursor.java:272)

It doesn't say why the argument is not valid though. Any ideas?

Greetings and thanks,