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


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

Re: BufferedImage and int[] array

Newsgroups comp.lang.java.programmer
Date 2017-04-21 09:03 -0700
References <5a1d0bab-5ae7-45a1-9c8f-344183ed48ba@googlegroups.com> <4f6d8eef-73e3-45f6-94fc-4ccb530ddd8c@googlegroups.com>
Message-ID <0f806bdc-aa93-4897-bb9f-8373ffd16175@googlegroups.com> (permalink)
Subject Re: BufferedImage and int[] array
From "Rick C. Hodgin" <rick.c.hodgin@gmail.com>

Show all headers | View raw


On Friday, April 21, 2017 at 11:54:16 AM UTC-4, Eric Douglas wrote:
> On Friday, April 21, 2017 at 11:29:07 AM UTC-4, Rick C. Hodgin wrote:
> > -----
> > I am basically trying to load an image, obtain an array to the raw
> > pixel data so I can manipulate each pixel directly in various ways,
> > including a colorize() algorithm, invert(), putBorder(), etc.
> > 
> > Thank you,
> > Rick C. Hodgin
> 
> I've never had a problem dealing with images and only using byte[] array.  I didn't even know images could or should be referenced as int[] array.  So I'd need specifics on what you're trying to do, either some code you wrote that's not working and/or the stackoverflow post you mentioned.  Otherwise I can only assume you're looking for this:
> https://stackoverflow.com/questions/12154090/creating-8-bit-image-from-byte-array

The underlying data in the byte[] array should already be in that
exact int[] format.  If I could cast the byte[] array into an int[],
then I could reference it as an int 4-bytes at a time.

Basically, I'm trying to do that without having to convert it as
the Stack Overflow link above indicates, because I want to be able
to access the byte[] data as that int[] form at any time.

Here's a reference on Stack Overflow:

    http://stackoverflow.com/questions/20852641/bufferedimage-int-pixels-and-rendering-how-do-they-work-they-work-together

It uses this code:

    int[] pixels = ((DataBufferInt)image.getRaster().getDataBuffer()).getData();

That apparently works when you have a 4-byte color depth, but if it's
not 4-bytes (32-bit) it doesn't work.  That's understandable, so I
need to know how to convert whatever format is loaded with the
IoImage.read() to then create a BufferedImage that is in 4-byte form?

Thank you,
Rick C. Hodgin

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


Thread

BufferedImage and int[] array "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-04-21 08:28 -0700
  Re: BufferedImage and int[] array Eric Douglas <e.d.programmer@gmail.com> - 2017-04-21 08:54 -0700
    Re: BufferedImage and int[] array "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-04-21 09:03 -0700
      Re: BufferedImage and int[] array Eric Douglas <e.d.programmer@gmail.com> - 2017-04-21 10:41 -0700
        Re: BufferedImage and int[] array Eric Douglas <e.d.programmer@gmail.com> - 2017-04-21 10:46 -0700
        Re: BufferedImage and int[] array "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-04-21 11:13 -0700
          Re: BufferedImage and int[] array Eric Douglas <e.d.programmer@gmail.com> - 2017-04-21 12:12 -0700
          Re: BufferedImage and int[] array Eric Douglas <e.d.programmer@gmail.com> - 2017-04-21 13:24 -0700
            Re: BufferedImage and int[] array "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-04-21 13:37 -0700
              Re: BufferedImage and int[] array "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-04-21 13:40 -0700
              Re: BufferedImage and int[] array Eric Douglas <e.d.programmer@gmail.com> - 2017-04-21 13:54 -0700
                Re: BufferedImage and int[] array "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-04-21 13:59 -0700
              Re: BufferedImage and int[] array Eric Douglas <e.d.programmer@gmail.com> - 2017-04-21 13:58 -0700
                Re: BufferedImage and int[] array "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-04-21 14:06 -0700
  Re: BufferedImage and int[] array Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-04-22 11:28 -0500
    Re: BufferedImage and int[] array "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-04-24 07:33 -0700
      Re: BufferedImage and int[] array Eric Douglas <e.d.programmer@gmail.com> - 2017-04-24 08:04 -0700
    Re: BufferedImage and int[] array "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-04-24 08:17 -0700
      Re: BufferedImage and int[] array Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2017-04-24 11:25 -0500

csiph-web