Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 321359 - Purple-icons drawing image with cairo in Solaris-sparc (big-endian)
Summary: Purple-icons drawing image with cairo in Solaris-sparc (big-endian)
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.6   Edit
Hardware: PC Solaris-GTK
: P3 normal (vote)
Target Milestone: 3.6.1   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-30 11:16 EDT by Silenio Quarti CLA
Modified: 2010-08-04 10:14 EDT (History)
1 user (show)

See Also:
eclipse.felipe: review+


Attachments
fix (3.89 KB, patch)
2010-07-30 11:25 EDT, Silenio Quarti CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Silenio Quarti CLA 2010-07-30 11:16:15 EDT
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;


public class Test {
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);

	shell.addListener(SWT.Paint, new Listener() {
		public void handleEvent(Event event) {
			GC gc = event.gc;
			Image image = new Image(gc.getDevice(), 100, 100);
			GC imageGC = new GC(image);
			imageGC.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_RED));
//			imageGC.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_GREEN));
//			imageGC.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_BLUE));
			imageGC.fillRectangle(image.getBounds());
			imageGC.dispose();
			
			ImageData data = image.getImageData();
			for (int y = 0; y < data.height; y++) {
				for (int x = 0; x < data.width; x++) {
					data.setAlpha(x, y, 0xFF);
				}
			}
			image.dispose();
			image = new Image(gc.getDevice(), data);
			
			gc.setAdvanced(true);
			System.out.println(gc.getAdvanced());
			gc.drawImage(image, 100, 100);
			
			image.dispose();
		}
	});

	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
}
Comment 1 Silenio Quarti CLA 2010-07-30 11:25:25 EDT
Created attachment 175586 [details]
fix
Comment 2 Silenio Quarti CLA 2010-07-30 11:27:45 EDT
Need to consider the native endianness when creating the cairo surface.

Fixed > 20100730.
Comment 3 Silenio Quarti CLA 2010-07-30 12:03:11 EDT
Felipe, please review for 3.6.1. Same patch applies.
Comment 4 Silenio Quarti CLA 2010-07-30 12:12:38 EDT
Patch has been released to R3_6_maintenance.