Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #23938

Re: How to convert image into Hex 2 Dimensional Array?

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: How to convert image into Hex 2 Dimensional Array?
Date 2013-05-08 12:52 -0400
Organization A noiseless patient Spider
Message-ID <kmdvmk$9ib$1@dont-email.me> (permalink)
References <41718873-b1a6-4b97-bbbb-8002c48d4e29@googlegroups.com> <GKCdnX3n1aHvmhfMnZ2dnUVZ8s6dnZ2d@bt.com> <kmdj5i$sk9$1@dont-email.me> <iqudnf7mvqsqxBfMnZ2dnUVZ7tSdnZ2d@bt.com> <_4uit.18441$MS1.11557@newsfe05.iad>

Show all headers | View raw


On 5/8/2013 11:22 AM, Daniel Pitts wrote:
> On 5/8/13 6:57 AM, lipska the kat wrote:
>> On 08/05/13 14:19, Daniele Futtorovic wrote:
>>> On 08/05/2013 10:06, lipska the kat allegedly wrote:
>>>>        Byte[][] bytes = new Byte[width][height];
>>>
>>> Lipska, mind the difference between Byte and byte. That code above is
>>> extremely bad advice.
>>
>> Why? it's common practice these days to eschew primitives and use
>> (autoboxing) classes
> Common practice where? Cite a credible source or I'll be forced to think
> that you are just making up facts to support your mistake.  My 4 year
> old daughter does that; you want to be more credible than my 4 year old,
> don't you?
>
>> it's more consistent in OO code and, as I
>> understand things, post autoboxing, the following two lines are
>> logically equivalent.
>>
>> 1. Byte[][] bytes = new Byte[width][height];
>> 2. byte[][] bytes = new byte[width][length]
>
> Even ignoring the typos, those are nothing alike.
>
> Auto-boxing is a convenience, but does not make those two things the
> same, even by a long shot.

    For example, consider what happens when `int x = bytes[0][0];'
immediately follows either of the above.  In case 2, it sets x
to zero.  In case 1, the JVM throws NullPointerException.  That's
not "logically equivalent" in my book!

>[...]
> Personally my decision on whether to use Byte vs byte would hinge solely
> on the question "do I want to store nulls in this?"

     Or on "Do I want to put it in a Collection?"

     There's also the matter of the memory footprint, even if
"efficiency" is a dirty word in some circles.  Version 1 will
use four times (32-bit JVM) or eight times (64-bit) as much
memory as version 2.  Image sizes vary, but even a fairly modest
640x480 has 300K pixels -- so using Byte[][] instead of byte[][]
would cost an extra 0.9MB or 2.1MB.  Even if I had the desire to
store nulls, a bloat of such proportions would probably prompt
me to use byte[][] and seek another way to represent whatever
I wanted the nulls to stand for.

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to convert image into Hex 2 Dimensional Array? sout saret <saretmis097@gmail.com> - 2013-05-07 23:30 -0700
  Re: How to convert image into Hex 2 Dimensional Array? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-05-08 09:06 +0100
    Re: How to convert image into Hex 2 Dimensional Array? Joerg Meier <joergmmeier@arcor.de> - 2013-05-08 12:29 +0200
      Re: How to convert image into Hex 2 Dimensional Array? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-05-08 13:28 +0100
    Re: How to convert image into Hex 2 Dimensional Array? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-05-08 15:19 +0200
      Re: How to convert image into Hex 2 Dimensional Array? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-05-08 14:57 +0100
        Re: How to convert image into Hex 2 Dimensional Array? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-05-08 08:22 -0700
          Re: How to convert image into Hex 2 Dimensional Array? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-05-08 17:03 +0100
            Re: How to convert image into Hex 2 Dimensional Array? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-05-08 13:44 -0700
          Re: How to convert image into Hex 2 Dimensional Array? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-05-08 17:48 +0100
            Re: How to convert image into Hex 2 Dimensional Array? Arne Vajhøj <arne@vajhoej.dk> - 2013-05-08 21:10 -0400
          Re: How to convert image into Hex 2 Dimensional Array? Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-05-08 12:52 -0400
        Re: How to convert image into Hex 2 Dimensional Array? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-05-08 17:32 +0200
          Re: How to convert image into Hex 2 Dimensional Array? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-05-08 17:17 +0100
            Re: How to convert image into Hex 2 Dimensional Array? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-05-08 18:46 +0200
              Re: How to convert image into Hex 2 Dimensional Array? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-05-08 18:25 +0100
                Re: How to convert image into Hex 2 Dimensional Array? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-05-08 23:24 +0200
        Re: How to convert image into Hex 2 Dimensional Array? Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2013-05-08 11:46 -0500
        Re: How to convert image into Hex 2 Dimensional Array? Arne Vajhøj <arne@vajhoej.dk> - 2013-05-08 21:04 -0400
          Re: How to convert image into Hex 2 Dimensional Array? Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-05-08 21:45 -0400
            Re: How to convert image into Hex 2 Dimensional Array? Arne Vajhøj <arne@vajhoej.dk> - 2013-05-08 21:59 -0400
              Re: How to convert image into Hex 2 Dimensional Array? Arne Vajhøj <arne@vajhoej.dk> - 2013-05-08 22:03 -0400
                Re: How to convert image into Hex 2 Dimensional Array? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-05-09 04:09 +0200
                Re: How to convert image into Hex 2 Dimensional Array? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-05-09 04:09 +0200
                Re: How to convert image into Hex 2 Dimensional Array? Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-05-08 23:18 -0400
                Re: How to convert image into Hex 2 Dimensional Array? Arne Vajhøj <arne@vajhoej.dk> - 2013-05-09 22:05 -0400
                Re: How to convert image into Hex 2 Dimensional Array? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-05-10 09:46 -0700
                Re: How to convert image into Hex 2 Dimensional Array? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-05-10 19:02 +0200
                Re: How to convert image into Hex 2 Dimensional Array? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-05-10 11:00 -0700
                Re: How to convert image into Hex 2 Dimensional Array? Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-05-10 23:42 +0200
                Re: How to convert image into Hex 2 Dimensional Array? Arne Vajhøj <arne@vajhoej.dk> - 2013-05-10 18:20 -0400
    Re: How to convert image into Hex 2 Dimensional Array? Jeff Higgins <jeff@invalid.invalid> - 2013-05-08 12:43 -0400
      Re: How to convert image into Hex 2 Dimensional Array? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-05-08 18:45 +0100
  Re: How to convert image into Hex 2 Dimensional Array? Jeff Higgins <jeff@invalid.invalid> - 2013-05-08 11:18 -0400
  Re: How to convert image into Hex 2 Dimensional Array? Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2013-05-08 11:52 -0500
    Re: How to convert image into Hex 2 Dimensional Array? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-05-08 18:40 +0100
      Re: How to convert image into Hex 2 Dimensional Array? Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2013-05-08 13:54 -0500
        Re: How to convert image into Hex 2 Dimensional Array? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-05-08 20:43 +0100
        Re: How to convert image into Hex 2 Dimensional Array? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-05-11 09:28 +0100
          Re: How to convert image into Hex 2 Dimensional Array? Arne Vajhøj <arne@vajhoej.dk> - 2013-05-11 08:50 -0400
            Re: How to convert image into Hex 2 Dimensional Array? lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-05-11 15:00 +0100
              Re: How to convert image into Hex 2 Dimensional Array? Arne Vajhøj <arne@vajhoej.dk> - 2013-05-12 21:45 -0400
  Re: How to convert image into Hex 2 Dimensional Array? Manuel Dahmen <manuel.dahmen@gmail.com> - 2013-05-08 15:38 -0700
  Re: How to convert image into Hex 2 Dimensional Array? Roedy Green <see_website@mindprod.com.invalid> - 2013-05-11 13:33 -0700
    Re: How to convert image into Hex 2 Dimensional Array? Arne Vajhøj <arne@vajhoej.dk> - 2013-05-12 21:48 -0400
      Re: How to convert image into Hex 2 Dimensional Array? markspace <markspace@nospam.nospam> - 2013-05-12 20:49 -0700
        Re: How to convert image into Hex 2 Dimensional Array? Arne Vajhøj <arne@vajhoej.dk> - 2013-05-13 19:08 -0400
        Re: How to convert image into Hex 2 Dimensional Array? Roedy Green <see_website@mindprod.com.invalid> - 2013-05-15 03:45 -0700
        Re: How to convert image into Hex 2 Dimensional Array? Roedy Green <see_website@mindprod.com.invalid> - 2013-05-15 03:50 -0700

csiph-web