🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #15331

Help! How to get RGB from BufferedImage

#15331
From: Qiang Song
Date: Thu, 17 Jun 1999 00:00
24 lines
1359 bytes
I have a BufferedImage and I want to get the RGB Data from it. The code
is written below, but I am not able to get what I want. Help is needed
and greatly appreciated.

    .....
    BufferedImage bi;
    width = bi.getWidth();
    height = bi.getHeight();
    cm = bi.getColorModel();
    Raster raster = bi.getRaster();
    DataBuffer dataBuffer = raster.getDataBuffer();
    int bank = raster.getNumBands();
    int dataType = raster.getTransferType();
    if (dataType != dataBuffer.TYPE_BYTE){
      throw new Exception("Unsupported Data Type!");
    }
    DataBufferByte dataBufferByte = (DataBufferByte) dataBuffer;
    if(bank == 1){
      pixels = (byte[]) dataBufferByte.getData().clone();
    }
    else if (bank == 3){
      RGBdata = new byte[3][width * height];
      RGBdata = dataBufferByte.getBankData();
    }
Technical Details
Message-ID: <3769DCC8.F6FBD0AD@kla-tencor.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,7989ef71e04fbb4a,start
X-Google-Attributes: gidf74b3,public
From: Qiang Song <qiang.song@kla-tencor.com>
Subject: Help! How to get RGB from BufferedImage
Date: 1999/06/17
Message-ID: <3769DCC8.F6FBD0AD@kla-tencor.com>
X-Deja-AN: 490954916
Content-Transfer-Encoding: 7bit
Organization: KLA-Tencor
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language