Results 1 to 10 of 10
  1. #1
    dvreed77 is offline Member
    Join Date
    Feb 2011
    Posts
    27
    Rep Power
    0

    Default Display DataBufferDouble as image

    Hello, I was hoping someone knew best practices concerning displaying data of type Double as an image through a BufferedReader. I have topography data that I would to show as an image. So the data is type Double that has an arbitrary range that I need to somehow map into RGB values. I feel there should be a way to create a ColorModel that will take care of this but am having trouble sorting through the API and have been unsuccessful trying to find an example. I was hoping to avoid manually mapping the topography data to RGB values since the data array may get very large and it seems inappropriate having two arrays floating around that have the exact same information.

    Any help would be appreciated

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,518
    Rep Power
    25

    Default Re: Display DataBufferDouble as image

    Double that has an arbitrary range that I need to somehow map into RGB values.
    The are about 16M RGB values to map to. How many double values do you have to map into those?

  3. #3
    dvreed77 is offline Member
    Join Date
    Feb 2011
    Posts
    27
    Rep Power
    0

    Default Re: Display DataBufferDouble as image

    Well I was hoping to create at most a mapping array. For example lets say I want to represent the topography with 256 colors. I some how create a colormap that say value 1 through 10 are RGB(0,0,0), 11 through 20 are RGB(0,0,20), etc. I haven't exactly figured out how I was going to pick the colors, and was going to just start off at grayscale first or use HSV and discretize the hue over a certain number of levels.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,518
    Rep Power
    25

    Default Re: Display DataBufferDouble as image

    It's probably an iterative process to get the colors you want.

  5. #5
    dvreed77 is offline Member
    Join Date
    Feb 2011
    Posts
    27
    Rep Power
    0

    Default Re: Display DataBufferDouble as image

    Could you expand on that? Choosing the colors isn't a big deal really. For example lets say the range of the typography are arbitrary doubles between 0 to 100. I say I want to represent this with 200 colors where values within the first 25 feet is represented by 50 shades of gray, second 25 feet is represented by shades of red, then green and so on. The problem is how do I tell Java that? The indexColorModel seems to do something similar, but this doesn't seem to work.

    Thanks for any help

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,518
    Rep Power
    25

    Default Re: Display DataBufferDouble as image

    how do I tell Java that
    Use the Color class's constructor to define colors.
    new Color(0xFF, 0, 0) would be red. Changing the values of the other args could generate other reds.
    Try using the JColorChooser to see the values. There is a section in the tutorial:
    How to Use Color Choosers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

  7. #7
    dvreed77 is offline Member
    Join Date
    Feb 2011
    Posts
    27
    Rep Power
    0

    Default Re: Display DataBufferDouble as image

    Thanks for the help. The problem I am having though is how to place my object of DataBufferDouble into a BufferedImage using an appropriate color model. I understand the Color object, but this doesn't provide a means of mapping my double values into RGB values for displaying as image.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,518
    Rep Power
    25

    Default Re: Display DataBufferDouble as image

    What is a DataBufferDouble?
    Is it two dimensional and the same size as the image you want to create? IE one double value to one pixel's color

  9. #9
    dvreed77 is offline Member
    Join Date
    Feb 2011
    Posts
    27
    Rep Power
    0

    Default Re: Display DataBufferDouble as image

    DataBufferDouble is a subclass of DataBuffer which is commonly used in WritableRaster objects used to create BufferedImages. Creating images with DataBufferInt for example isn't trivial, but I can do it. In that case the Integer in the DataBufferInt array is what they call a packed value. Since ARGB is 32 bits and an Integer is 32 bits each value represents an ARGB value. It looks like I'm going to have to manually map my double array to an integer array an then create a buffered image from there. I was hoping to avoid that, but it looks to be the only way.

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,518
    Rep Power
    25

    Default Re: Display DataBufferDouble as image

    The A of ARGB is the transparency byte. For color you use the 24 lower bits.

Similar Threads

  1. Display Image (png)
    By vimalaranjan in forum Java Gaming
    Replies: 2
    Last Post: 05-04-2011, 12:23 AM
  2. to display image
    By asmitarnd in forum AWT / Swing
    Replies: 6
    Last Post: 04-07-2011, 11:17 AM
  3. image display
    By asmitarnd in forum AWT / Swing
    Replies: 3
    Last Post: 04-07-2011, 11:17 AM
  4. How to display image ?
    By Birkoff in forum AWT / Swing
    Replies: 7
    Last Post: 06-09-2008, 07:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •