ar.com.hjg.pngj
Class ImageLine

java.lang.Object
  extended by ar.com.hjg.pngj.ImageLine

public class ImageLine
extends Object

Lightweight wrapper for an image scanline, used for read and write.

This object can be (usually it is) reused while iterating over the image lines.

See scanline field, to understand the format.


Field Summary
 ImageInfo imgInfo
           
 int[] scanline
          The 'scanline' is an array of integers, corresponds to an image line (row).
 
Constructor Summary
ImageLine(ImageInfo imgInfo)
           
 
Method Summary
 FilterType getFilterUsed()
           
 int getRown()
          This row number inside the image (0 is top)
 int[] getScanLineCopy(int[] b)
          Returns a copy from scanline, in byte array.
 void incRown()
          Increments row number
 void pack(int[] buf, boolean scale)
          Packs scanline (for bitdepth 1-2-4) from array into the scanline If scale==true, it scales the value (just a bit shift).
 void setFilterUsed(FilterType ft)
           
 void setRown(int n)
          Sets row number (0 : Rows-1)
 void setScanLine(int[] b)
          Sets scanline, making copy from passed array.
static void showLineInfo(ImageLine line)
          Prints some statistics - just for debugging
 String toString()
          Basic info
 int[] unpack(int[] buf, boolean scale)
          Unpacks scanline (for bitdepth 1-2-4) into a array int[] You can (OPTIONALLY) pass an preallocated array, that will be filled and returned.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

imgInfo

public final ImageInfo imgInfo

scanline

public final int[] scanline
The 'scanline' is an array of integers, corresponds to an image line (row).

Except for 'packed' formats (gray/indexed with 1-2-4 bitdepth) each int is a "sample" (one for channel), (0-255 or 0-65535) in the corresponding PNG sequence: R G B R G B... or R G B A R G B A... or g g g ... or i i i (palette index)

For bitdepth=1/2/4 , each value is a PACKED byte! To get an unpacked copy, see tf_pack() and its inverse tf_unpack()

To convert a indexed line to RGB balues, see ImageLineHelper.palIdx2RGB() (you can't do the reverse)

Constructor Detail

ImageLine

public ImageLine(ImageInfo imgInfo)
Method Detail

getFilterUsed

public FilterType getFilterUsed()

getRown

public int getRown()
This row number inside the image (0 is top)


getScanLineCopy

public int[] getScanLineCopy(int[] b)
Returns a copy from scanline, in byte array.

You can (OPTIONALLY) pass an preallocated array to use.

You should rarely use this


incRown

public void incRown()
Increments row number


pack

public void pack(int[] buf,
                 boolean scale)
Packs scanline (for bitdepth 1-2-4) from array into the scanline

If scale==true, it scales the value (just a bit shift).


setFilterUsed

public void setFilterUsed(FilterType ft)

setRown

public void setRown(int n)
Sets row number (0 : Rows-1)


setScanLine

public void setScanLine(int[] b)
Sets scanline, making copy from passed array. You'd rarely use this


showLineInfo

public static void showLineInfo(ImageLine line)
Prints some statistics - just for debugging


toString

public String toString()
Basic info

Overrides:
toString in class Object

unpack

public int[] unpack(int[] buf,
                    boolean scale)
Unpacks scanline (for bitdepth 1-2-4) into a array int[]

You can (OPTIONALLY) pass an preallocated array, that will be filled and returned. If null, it will be allocated

If scale==true, it scales the value (just a bit shift) towards 0-255.