Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?B?Sm9zaHVhIENyYW5tZXIg8J+Qpw==?= Newsgroups: comp.lang.java.programmer Subject: Re: How to convert image into Hex 2 Dimensional Array? Date: Wed, 08 May 2013 13:54:05 -0500 Organization: A noiseless patient Spider Lines: 44 Message-ID: References: <41718873-b1a6-4b97-bbbb-8002c48d4e29@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Wed, 8 May 2013 18:50:30 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="95ab4c362dcce54022543f80bbbb46d3"; logging-data="21069"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19seucXP15OplT0sm8uQvbBwNYZUJUO8O0=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Thunderbird/21.0 In-Reply-To: Cancel-Lock: sha1:97EjaW2gBL7EeKDM8lrMV7YNeTU= Xref: csiph.com comp.lang.java.programmer:23944 On 5/8/2013 12:40 PM, lipska the kat wrote: > On 08/05/13 17:52, Joshua Cranmer 🐧 wrote: >> On 5/8/2013 1:30 AM, sout saret wrote: >>> Dear Community! >>> >>> May you help me how to write code in java to convert image to Hex 2 >>> dimensional array. I want to show format as below: >> >> What format is this two-dimensional array? Looking from your code, you >> appear to want it to be some sort of 256-byte pixel value, but are you >> desiring: >> 1. 8-bit ARGB >> 2. 5-6-5 RGB >> 3. 8-bit grayscale >> 4. 32-bit ARGB >> 5. 24-bit RGB >> 6. Binary version of any widely-used image format, including but not >> limited to PNG, BMP, GIF, JPG, XBM, TIF, and ICO. > > I think he wants a byte for byte copy so the first byte gets copied into > [0][0] the next into [1][0] the next [2][0] etc until [width-1][0] > then start again at [0][1], [1][1], [2][1] etc etc A byte for byte copy of what? I'm guessing the answer is the "pixel matrix", but that's underdefined since pixels can take on many different formats, which is what I was trying to get at--what encoding of a pixel is desired? Things get even more fun if you don't want an RGB colorspace--HSL is often better for manipulation, but YCbCr or CIELAB are more representative of how the human eye perceives color and are used in lossy compression and scientific image processing, for that reason. Also, even just RGB is a meaningless term because there are several different RGB colorspaces, the most common being sRGB and Adobe RGB. If you just want to statically convert an image into this format for use as an internal resource, I'd recommend not coding it in Java but using ImageMagick to convert the image to something like PBM which specifies the pixel data in a simple ASCII format: . -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth