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


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

Re: BufferedImage and int[] array

Newsgroups comp.lang.java.programmer
Date 2017-04-21 13:37 -0700
References (1 earlier) <4f6d8eef-73e3-45f6-94fc-4ccb530ddd8c@googlegroups.com> <0f806bdc-aa93-4897-bb9f-8373ffd16175@googlegroups.com> <903d6ec5-ab8e-4e87-9581-13ff803bf461@googlegroups.com> <a2ae1966-1dc0-4019-8286-16a5825ba843@googlegroups.com> <125e8758-3bf6-453b-8c5c-cadd339a0ebf@googlegroups.com>
Message-ID <e09756ab-7d8b-49ea-a529-6d6b71a8554f@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 4:24:47 PM UTC-4, Eric Douglas wrote:
> With a real lack of comments in your code I'm not sure what each
> section is trying to accomplish.
> Taking a guess your invert method wants to turn the image upside down,
> I googled that and found this working code.

That code was all written last night and when I ran into the issue
with reading in a transparent enabled PNG file and it losing the
alpha channel I sort of stopped.

The algorithm is inverting the color.  This line reverses the color
of each pixel color channel:

    Line 275:
    pixels[offset] = rgba(255 - red, 255 - grn, 255 - blu, 0);
    http://www.libsf.org:8990/projects/LIB/repos/libsf/browse/king/keyboard_driver/gui/src/gui/BufferedImage3.java

The 255 - red computes the inverted color of the red channel, and
it repeats for green, blue, and sets the alpha channel to 0, which
is a bug and should be using the originally derived alp value on
line 220, once it's copied down into that function. :-)

I'll look at your solution.  I'm really thinking I don't need to
do anything other than load in the PNG as a 3-byte BGR format,
and then create a second PNG in the 4-byte ARGB format, and then
obtain WritableRaster objects and draw the image from one to the
other, which should handle the translation, and then delete the
3-byte BGR version.

Do you feel so inclined to write code to test that method out?
I only ask because you've been far more helpful than I would've
expected someone to be on Usenet. :-)  I plan on working on it
tonight.  I've only programmed in Java one time previously back
in 2011 on a project used to automate tests on hardware:

    Office Productivity Benchmark
    https://github.com/RickCHodgin/opbm

A lot of code written mostly from May-July 2011.  I'm sure it
has lots of errors in it, but I was on my own in trying to do
everything.  I used Stack Overflow and the javadoc help files.

That one was written in NetBeans 8.0 I believe.

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