Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #3602 > unrolled thread
| Started by | "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:45 +0000 |
| Last post | 2011-04-27 15:45 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.java.gui
Re: 4-byte greyscale imag "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
Re: 4-byte greyscale imag Paul.Lee.1971@gmail.com.remove-dii-this - 2011-04-27 15:45 +0000
| From | "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:45 +0000 |
| Subject | Re: 4-byte greyscale imag |
| Message-ID | <g23jb0$pmb$1@registered.motzarella.org> |
To: comp.lang.java.gui On 2008-06-03 16:02 +0100, Paul.Lee.1971@gmail.com allegedly wrote: > Hi everyone, > Hopefully someone can help me, this is really "bugging me" ! > > I have a RGB image, and I'm trying to get the Y Luminance component to > display and manipulate. I think I've done something that goes someway > to solving this: > > BufferedImage greyImage=new > BufferedImage(img.getWidth(),img.getHeight(),BufferedImage.TYPE_BYTE_GRAY); > greyImage.getGraphics().drawImage(img,0,0,null); > > The problem now is that the image is an 8 bit grayscale image. What > I'd like to be able to do is draw colours transparently on top of the > grey image; in effect "colouring in" the image but leaving the details > of the background untouched. For that I think I'd need RGB and alpha > values; how can I covert the 8 bit grayscale to 32 bit/1 int > grayscale? Make the three lower bytes of your int the same value as your byte (8 bit int). The topmost byte defines alpha (0x0->transparent; 0xff->opaque). -- DF. to reply privately, change the top-level domain in the FROM address from "invalid" to "net" --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | Paul.Lee.1971@gmail.com.remove-dii-this |
|---|---|
| Date | 2011-04-27 15:45 +0000 |
| Message-ID | <6d4dee14-36f8-4b7e-b4c3-fcff457aeba3@m45g2000hsb.googlegroups.com> |
| In reply to | #3602 |
To: comp.lang.java.gui
Great, thanks! I think I realised after about 2 seconds after I posted
that how to convert 8-bit grey to 24-bit color (albeit in grey :)
BufferedImage greycolorimage = new
BufferedImage(greyimage.getWidth(),greyimage.getHeight
(),BufferedImage.TYPE_4BYTE_ABGR); // greyimage is the original,
TYPE_BYTE_GRAY image
greycolorimage.getGraphics().drawImage(greycolorimage,0,0,null);
Interestingly, I can't seem to write this out using:
File output = new File("image.bmp");
ImageIO.write(greycolorimage, "bmp", output);
If I display the image in a JFrame, it looks fine, but I wanted to
inspect the size of it to make sure that it
was 4-byte. How frustrating!
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web