Summary: | gradient fill does not print its color properly | ||
---|---|---|---|
Product: | [Eclipse Project] Platform | Reporter: | Karice McIntyre <Karice_McIntyre> |
Component: | SWT | Assignee: | Carolyn MacLeod <carolynmacleod4> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P1 | CC: | veronika_irvine |
Version: | 2.1 | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Karice McIntyre
2003-09-30 11:51:44 EDT
Tried it on eclipse 3.0 M4. The colors are ok when printed from Windows XP, but they are wrong when printed from Windows 2000. The printer is an IBM Infoprint Color 1220. I also rewrote the snippet so that printing is done directly to the printer, instead of to a background image. Same problem (the color yellow is printed as turquoise). Here is the rewritten snippet: import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; import org.eclipse.swt.printing.*; public class PrintColorGradient { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); FontDialog fontDialog = new FontDialog(shell, SWT.NULL); FontData displayFontData = fontDialog.open(); PrintDialog dialog = new PrintDialog(shell, SWT.NULL); PrinterData data = dialog.open(); shell.dispose(); if (displayFontData == null || data == null) { System.out.println("Cancelled"); return; } Printer printer = new Printer(data); Rectangle clientArea = printer.getClientArea(); Font printerFont = new Font(printer, displayFontData.getName (), displayFontData.getHeight(), SWT.NORMAL); // this is the color that causes the problem Color foreground = new Color(printer, 255, 252, 194); // yellow Color background = new Color(printer, 0xff, 0xff, 0xff); if (printer.startJob("Gradient Color Test")) { Rectangle trim = printer.computeTrim(0, 0, 0, 0); Point dpi = printer.getDPI(); int leftMargin = dpi.x + trim.x; // one inch from left side of paper int topMargin = dpi.y / 2 + trim.y; // one-half inch from top edge of paper GC gc = new GC(printer); if (printer.startPage()) { gc.setFont(printerFont); gc.setForeground(foreground); gc.setBackground(background); Rectangle rect = new Rectangle(20, 20, clientArea.width / 2, clientArea.height / 4); gc.drawRectangle(rect); gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height, false); gc.drawString("Test", 222, 222); gc.dispose(); printer.endPage(); } printer.endJob(); } } } This still doesn't work in 3.0 M8 (Win2k). We would really like this fixed for Eclipse 3.0 I can't get to it right away, but I am marking it P1 so that it goes to the top of my pile (note that I do have several P1's). If it turns out to be a platform limitation, I will try to come up with a suitable workaround, such as filling the gradient using fillRectangle instead, and doing a bit of math. VI, do you have any experience with filling gradients without using the platform gradient method? Also, do you happen to have any experience with this bug (Printer uses a different color when you use GC.fillGradientRectangle)? Fixed > 20040505. We emulate the gradient fill for printing now. It was failing on Win98 and Win2K. |