Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #126
| From | "hiwa" <hiwa@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: How to do image-type |
| Message-ID | <1163763334.110753.116650@b28g2000cwb.googlegroups.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <1163755756.272634.317060@m7g2000cwm.googlegroups.com><e |
| Date | 2011-04-27 15:25 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
Thomas Weidenfeller wrote:
> hiwa wrote:
> > I'd like to convert a standard TYPE_INT_ARGB BufferedImage to a
> > TYPE_BYTE_BINARY one. Getting simple black and white ARGB image from
> > original image was a piece of cake. However, I have no clue from there
> > on.
>
> You did not tell us what you want to achieve. So the following should
> give you what you asked for, but it might not be what you really want:
>
> BufferedImage argb = ...
>
> BufferedImage bb = new BufferedImage(
> argb.getWidth(),
> argb.getHeight(),
> TYPE_BYTE_BINARY);
> Graphics2D g = bb.createGraphics();
> bb.drawImage(argb, 0, 0, null);
>
> Note: Not using an image observer can get you in trouble, e.g. if argb
> is not completely loaded when you try to draw it on bb. But you get the
> idea.
>
> /Thomas
I tried that method first but what I got was a all black image --
darkness, darkness, be my pillow...
When I tried blue&white instead of black&white, what I got was a all
blue image -- deep deep sea all around us...
----------------------------------------
byte b = (byte)255;
icm = new IndexColorModel
(1, 2, new byte[]{0, b}, new byte[]{0, b}, new byte[] {b, b});
bw = new BufferedImage(scrw, scrh, TYPE_BYTE_BINARY, icm);
----------------------------------------
---
* 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
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
How to do image-type conv "hiwa" <hiwa@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
Re: How to do image-type "hiwa" <hiwa@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
Re: How to do image-type "Thomas Fritsch" <thomas.fritsch@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
Re: How to do image-type "Thomas Weidenfeller" <thomas.weidenfeller@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
Re: How to do image-type "hiwa" <hiwa@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
csiph-web