|
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); ----------------------------------------
|
|
0
|
|
|
Reply
|
hiwa
|
11/17/2006 11:35:34 AM
|
Header
|
Report
as Spam
|
|
hiwa schrieb: > 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. > > I tried that method first but what I got was a all black image -- > darkness, darkness, be my pillow...
It is because the renderer does no dithering. In theory you might get dithering by inserting this line: g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE); But in practice (in my Java 1.4.2 and 1.5.0) I get the same un-dithered image as before. :-(
-- Thomas
|
|
0
|
|
|
Reply
|
Thomas
|
11/17/2006 3:56:41 PM
|
Header
|
Report
as Spam
|
|
Thomas Fritsch wrote: > It is because the renderer does no dithering. Sorry, it was my coding error. Correct code is: ---------------------------------------------------------------------- byte b = (byte)255; icm = new IndexColorModel (1, 2, new byte[]{b, 0}, new byte[]{b, 0}, new byte[] {b, b});//Blue on White bw = new BufferedImage(scrw, scrh, TYPE_BYTE_BINARY, icm); ---------------------------------------------------------------------- And, yes, it doesn't do dithering. Ugly image!
|
|
0
|
|
|
Reply
|
hiwa
|
11/18/2006 1:01:00 AM
|
Header
|
Report
as Spam
|
|
4 Replies
165 Views
Similiar Articles: Text to Voice conversion in matlab - comp.soft-sys.matlab ...I have image of Text book, And I extracted somehow the text from that image. ... Data Type Conversion (Database Engine) - MSDN – Explore Windows ... Read formatted data ... steps to convert RGB (colored image) to binary? - comp.soft-sys ...type "help help" for help command options, such ... where x is the binary image, ought to do. Of course, it ... RGB to Binary Image Conversion (Only the Large White Region) ... how to insert <</Type/Annot into a pdf programmatically ...... ImageMagick/Ghostscript or iTextSharp I can do the conversion. ... <</Type/Annot /MyStuff << /Label (id) /AnotherLabel (id) ... friendly" view of the form (with the signature image ... Overcoming insufficient permissions for PDF image extraction to ...> do all of these conversions, and more.) Again, you need to read the contract. ... Overcoming insufficient permissions for PDF image extraction to ..... Save As, Save as type ... Conversion to non-scalar type - comp.lang.c++.moderatedSuppose I have a template class Vector and I define a child class Indices : public Vector { public: Indices(const Vector &v); .... } Now... Conversion from Cartesian Coordinates to Matlab Coordinates - comp ...> > I would like to know how to do the conversion to Matlab co-ord ... filter with a 3 by 3 structuring element on an image ... Type "polar_coordinate = cart2pol(cartesian ... Need help with map projection conversion in ENVI - comp.lang.idl ...ENVI_WRITE_ENVI_FILE, data, DATA_TYPE=data_type, /NO_OPEN, $ ... registration and projection conversion Do map projection conversion Open and load ... img image file. to do ... Pixel to metric unit conversion - comp.soft-sys.matlabimage. The returned value is in pixel and I would like to convert it to ... programmer's calculator - comp.lang.java.help > Perhaps one that could do conversion of ... Conversion of 2D to 1D - comp.lang.idl-pvwaveHi, How can we convert a 2D array (image) into 1D in IDL? Plz reply ... itags.org: Matlab question: Convert 1D to 2D Hanning window. ... conversion of 2D image into ... Creating 1-bit PCX graphic files? - comp.os.os2.multimedia ...pmView, such as 1-bit BMP, do not show right). But - Image Magick ignores ... any other automated conversion tools which can ... way to combinations of -depth, -color, -type ... 'Convert Image' - Document Comparison and Document Conversion ...'Convert Image' is a simple to use, yet sophisticated image conversion ... Type Constants. / C # tells ‘Convert Image’ what the target file type ... Converting One File Type to Another - FILExt - The File Extension ...Converting One File Type to Another ... or IrfanView to both read and display the image as ... to PC format on a PC (it's usually best to do the conversion on ... OS X Automated Image Type Conversion and Resize - YouTubeDemonstration video of Macintosh OS X automation capabilities. Video shows the conversion of image file type and image scale or re-size using a Folder ... How to Convert an Image to a True Type Font | eHow.comHow to Convert an Image to a True Type Font. You can easily convert ... enable you to pick and choose the parts of the image you wish to convert. After making the conversion ... Image Converter - Online Utility - Free Online Software, Computer ...Image Converter This is on-line image converter. It supports over 100 major image ... file type : JPEG 5/16/2012 9:52:21 AM
|