Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 24977 Details for
Bug 103691
Misidentification of transparent pixels
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
More correct SWT app to demonstrate the problem
ColorTest.java (text/x-java), 3.93 KB, created by
David Walser
on 2005-07-19 10:40:20 EDT
(
hide
)
Description:
More correct SWT app to demonstrate the problem
Filename:
MIME Type:
Creator:
David Walser
Created:
2005-07-19 10:40:20 EDT
Size:
3.93 KB
patch
obsolete
>import org.eclipse.swt.SWT; >import org.eclipse.swt.graphics.*; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Label; >import org.eclipse.swt.widgets.Shell; > >/* > * Created on Jul 5, 2005 > * > * To change the template for this generated file go to > * Window - Preferences - Java - Code Generation - Code and Comments > */ > >public class ColorTest { > >// public static byte byteMe(String prompt) { >// System.out.print(prompt + " "); >// return Byte.parseByte(Stdin.readLine()); >// } > > private static byte LO = 0; > private static byte MID = 1; > private static byte HI = 2; > > private static float markOrigColor (byte orig[]) { > int foo[] = new int[3]; > for (int i=0;i < 3;i++) > foo[i] = orig[i]<0?orig[i]+256:orig[i]; > > int hi, lo, mid; > hi = lo = mid = foo[0]; > for (int i=1;i < 3;i++) > if (foo[i] > hi) { > mid = hi; > hi = foo[i]; > } > else if (foo[i] < lo) { > mid = lo; > lo = foo[i]; > } > else > mid = foo[i]; > > for (int i=0;i < 3;i++) > if (foo[i] == hi) > orig[i] = HI; > else if (foo[i] == lo) > orig[i] = LO; > else > orig[i] = MID; > > return (mid-lo)/(float)(hi-lo); > } > > private static void colorize(ImageData data, byte orig[], float midratio) { > for (int y=0;y < data.height;y++) > for (int x=0;x < data.width;x++) { > int pixel = data.getPixel(x, y); > if (pixel == data.transparentPixel) { > data.setPixel(x, y, data.palette.getPixel(new RGB(0, 0, 255))); > continue; > } > > RGB pixelValue = data.palette.getRGB(data.getPixel(x, y)); > int foo[] = new int[] {pixelValue.red, pixelValue.green, pixelValue.blue}; > int hi, lo, mid; > hi = lo = mid = foo[0]; > for (int i=1;i < 3;i++) > if (foo[i] > hi) { > mid = hi; > hi = foo[i]; > } > else if (foo[i] < lo) { > mid = lo; > lo = foo[i]; > } > else > mid = foo[i]; > > float mul = ((hi+mid+lo) / 765.0f * 255 - hi) / hi; > hi += mul*hi; >// mid += mul*mid; > lo += mul*lo; > >// mul = ((hi+mid+lo) / 765.0f * hi - lo) / (hi-lo+1); >// mid += mul*(hi-mid); >// lo += mul*(hi-lo); > > int sat = 100*(255 - lo) / (hi+1); >// lo = mid = hi; > float dif = (255 - (hi-lo))/(float)255; > hi *= 1+dif; > if (hi > 255) > hi = 255; > lo -= (sat+0*dif); > if (lo < 0) > lo = 0; >// mid *= 1+(.5f*dif); >// if (mid > 255) >// mid = 255; >// mid -= sat/2; >// if (mid < 0) >// mid = 0; > mid = (int) (midratio*(hi-lo) + lo); > >// float mul; >// int sum = lo+mid+hi; >// if (sum < 510) { >// mul = Math.abs(255-sum)/255.0f; >// mul = 1 - (1-mul)/4; >// hi *= mul; >// lo *= mul; >// mid *= mul; >// } >// if (sum > 255) { >// mul = Math.abs(510-sum)/255.0f; >// mul = 1 - (1-mul)/4; >// hi += (255-hi)*mul; >// lo += (255-lo)*mul; >// mid += (255-mid)*mul; >// } > > for (int i=0;i < 3;i++) > if (orig[i] == HI) > foo[i] = hi; > else if (orig[i] == LO) > foo[i] = lo; > else > foo[i] = mid; > data.setPixel(x, y, data.palette.getPixel(new RGB(foo[0], foo[1], foo[2]))); > } > } > > public static void printArray(byte bites[]) { > System.out.print("["); > for (int i=0;i < 2;i++) > System.out.print((bites[i]<0?bites[i]+256:bites[i]) + ", "); > System.out.println((bites[2]<0?bites[2]+256:bites[2]) + "]"); > } > > /** > * @param args > */ > public static void main(String[] args) { > byte orig[] = {(byte) 255, (byte) 64, (byte) 0}; > float midratio = markOrigColor(orig); > > Display display = new Display (); > final Shell shell = new Shell(display); > > final Label label = new Label(shell,SWT.BORDER); > Image image = new Image(display, "../JavaMBS/smallfish.gif"); > ImageData data = image.getImageData(); > > colorize(data, orig, midratio); > > image = new Image(display,data); > > label.setBounds(image.getBounds()); > shell.pack(); > > label.setImage(image); > > shell.open(); > while (!shell.isDisposed ()) { > if (!display.readAndDispatch ()) display.sleep (); > } > //shell.dispose(); > display.dispose(); > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 103691
:
24684
|
24685
| 24977