Chapter 5 - Class Snow.Snowbnd Methods

This chapter describes the available methods for the Snow.Snowbnd class. The chapter contains the following topics:

‘‘display_angle(int)’’

‘‘finalize(void)’’

‘‘fit_to_height(int)’’

‘‘fit_to_width(int)’’

‘‘getBitsPerPixel(void)’’

‘‘get_fit_to_height()’’

‘‘get_fit_to_width()’’

‘‘getHeight(void)’’

‘‘getInitialZoom(int, int)’’

‘‘getWidth(void)’’

‘‘getXdpi(void)’’

‘‘getYdpi(void)’’

‘‘IMG_antique_effect(void)’’

‘IMG_autocrop_bitmap(int, int)’’

‘IMG_auto_orient(Snow.Snowbnd, int)’’

‘‘IMG_color_gray(void)’’

‘‘IMG_create_thumbnail(int, int)’’

‘‘IMG_decompress_bitmap(String, int)’’

‘‘IMG_decompress_bitmap(java.awt.Image, int)’’

‘‘IMG_decompress_bitmap(java.io.DataInputStream, int)’’

‘‘IMG_decompress_bitmap_fd(String, int, int)’’

‘‘IMG_decompress_bitmap_stream(String, int)’’

‘‘IMG_decompress_bitmap_stream_onthefly(String, int, java.awt.Container)’’

‘‘IMG_decompress_fax(java.lang.String, int, int, int, int, int)’’

‘‘IMG_decompress_fax(java.io.DataInputStream, int, int, int, int, int)’’

‘‘IMG_decompress_multipage_bitmap_stream_onthefly(String, int, java.awt.Container)’’

‘‘IMG_deskew_bitmap(int)’’

‘‘IMG_despeckel_bitmap(int)’’

‘‘IMG_diffusion_mono(void)’’

‘‘IMG_display_bitmap(java.awt.Graphics, int, int, int, int)’’

‘‘IMG_display_bitmap_aspect(java.awt.Graphics, java.awt.Container, int, int, int, int, int)’’

‘IMG_display_bitmap_smooth(java.awt.Graphics, java.awt.Container, int, int, int, int, int)’’

‘‘IMG_erase_rect(int, int, int, int, int, int, int)’’

‘‘IMG_fill_bitmap_pattern(int, int, int, int, int, int, int, int, byte[])’’

‘‘IMG_flip_bitmapx(void)’’

‘‘IMG_flip_bitmapy(void)’’

‘‘IMG_get_bitmap_block(int, int, int, int)’’

‘‘IMG_get_deskew_angle(int[], int, int)’’

‘‘IMG_invert_bitmap(void)’’

‘‘IMG_merge_block(Snow.Snowbnd, int, int, int)’’

‘‘IMG_print_applet(java.awt.Container, int)’’

‘‘IMG_print_applet_pages(java.awt.Container, int)’’

‘‘IMG_print_bitmap(java.awt.Graphics, int, int, int, int, int)’’

‘‘IMG_promote_24(void)’’

‘‘IMG_remove_red_eye(int, int, int, int)’’

‘‘IMG_resize_bitmap(int, int)’’

‘‘IMG_resize_bitmap_bicubic(int, int)’’

‘‘IMG_resize_to_gray(int, int)’’

‘‘IMG_rgb_to_cmyk(void)’’

‘‘IMG_rotate_bitmap(int)’’

‘‘IMG_save_bitmap(byte, int)’’

‘‘IMG_save_bitmap(byte, int, int, int)’’

‘‘IMG_save_bitmap(int, int, int, int)’’

‘‘IMG_save_bitmap(String, int)’’

‘IMG_save_document(String, byte, int)’’

‘IMG_save_document(byte, byte, int)’’

‘‘IMG_scroll_bitmap(java.awt.Container, java.awt.Event)’’

‘‘IMG_set_croprect(int, int, int, int)’’

‘‘IMG_shift_bitmap(int, int)’’

‘‘IMG_window_level(int, int, int)’’

‘‘IMGLOW_extract_page(String, int, int)’’

‘‘IMGLOW_extract_page(java.io.DataInputStream, int, int)’’

‘‘IMGLOW_extract_text(String, int, int, int)’’

‘‘IMGLOW_get_brightness()’’

‘‘IMGLOW_get_contrast()’’

‘‘IMGLOW_get_fileinfo(java.io.DataInputStream, int)’’

‘‘IMGLOW_get_filetype(String)’’

‘‘IMGLOW_get_filetype(java.io.DataInputStream)’’

‘‘IMGLOW_get_gamma()’’

‘‘IMGLOW_get_image_orientation(void)’’

‘‘IMGLOW_get_pages(java.io.DataInputStream)’’

‘‘IMGLOW_get_pages(String)’’

‘IMGLOW_get_raster(int, byte[])’’

‘‘IMGLOW_get_tiff_tag(int, int, int[], java.io.DataInputStream, byte[], int) IMGLOW_get_tiff_tag(int, int, int[], String, byte[], int)’’

‘‘IMGLOW_get_warnings()’’

‘IMGLOW_put_raster(int, byte[])’’

‘‘IMGLOW_search_text(byte[], String, int, int, int[])’’

‘‘IMGLOW_set_ascii_attributes(int, int, int, int, int, int, int, int, int, int, int, int, boolean, boolean, String, int, double)’’

‘‘IMGLOW_set_brightness(int)’’

‘‘IMGLOW_set_comp_quality(int)’’

‘‘IMGLOW_set_contrast(int)’’

‘‘IMGLOW_set_decompsize(int, int)’’

‘‘IMGLOW_set_decomp_rect(int, int, int, int)’’

‘‘IMGLOW_set_document_input(int, int)’’

‘IMGLOW_set_fast_convert(int, int)’’

‘‘IMGLOW_set_gamma(int)’’

‘‘IMGLOW_set_image_orientation(int)’’

‘‘IMGLOW_set_jpg_interleave(int, int)’’

‘‘IMGLOW_set_overlay_path(String)’’

‘‘IMGLOW_set_pcl_input(int, int)’’

‘‘IMGLOW_set_pdf_input(int, int)’’

‘‘IMGLOW_set_pdf_output(int, int)’’

‘‘IMGLOW_set_tiff_tag(int, int, int, byte[])’’

‘IMGLOW_set_UTF_8(int)’’

‘‘IMGLOW_write_tiff_stream(Dib_Head lpbi, byte, int, int, String)’’

‘‘map_image_to_wnd(java.awt.Container, java.awt.Point)’’

‘‘map_wnd_to_image(java.awt.Container, java.awt.Point)’’

‘‘set_croprect(int, int, int, int)’’

‘‘set_croprect_scroll(java.awt.Container, int, int, int, int, int)’’

‘‘setFrame(java.awt.Container)’’

‘‘setXdpi(int)’’

‘‘setYdpi(int)’’

‘‘Snowbnd(int, int, int)’’

‘‘Snowbnd(Snowbnd)’’

display_angle(int)

This method rotates the image at display time. The data itself is not changed, but the image is painted at the requested angle. This method is extremely fast, and is the recommended method for rotating when it is unnecessary to permanently change the image data.

See ‘‘IMG_rotate_bitmap(int)’’ for more information.

Syntax

void display_angle(int angle);

Remark

Table 5-1 lists the display_angle(int) method setting descriptions.

Table 5-1: display_angle(int) Method Settings

Setting

Description

angle

The display angle. Valid values are 0, 90, 180, and 270 degrees.

_________________________________________________________________________

Example

if (myPanel.Simage != null)
{
      
myPanel.Simage.display_angle(0);
      
myPanel.repaint();
}

________________________________________________________________________

finalize(void)

This method is a recommended call when a Snowbnd object is no longer needed.

Notes:
 
If scrollbars are used, failure to call this method may result in a resource leak.
Calling this method before the system has completed all requested operations may result in NullPointerExceptions or ArrayIndexOutOfBoundsExceptions. It is important to be particularly vigilant when calling this method in multithreaded environments.

Syntax

void finalize();

fit_to_height(int)

This method turns on an internal flag that forces the IMG_display_bitmap_aspect method to display by fitting the width of the image to the height of the Container, minus the height of the scroll bars, if any.

See ‘‘IMG_display_bitmap_aspect(java.awt.Graphics, java.awt.Container, int, int, int, int, int)’’ for more information.

Syntax

void fit_to_height(int flag);

Remark

Table 5-2 lists the fit_to_height(int) method variable descriptions.

Table 5-2: fit_to_height(int) Method Variables

Variable

Description

flag

0 = Method is off.
1 = Method is on.

_________________________________________________________________________

Example

myPanel1.zoom = 0;
myPanel1.Simage.fit_to_height(1);
myPanel1.repaint();

_________________________________________________________________________

fit_to_width(int)

This method turns on an internal flag that forces the IMG_display_bitmap_aspect method to display by fitting the width of the image to the width of the Container, minus the width of the scroll bars, if any.

See ‘‘IMG_display_bitmap_aspect(java.awt.Graphics, java.awt.Container, int, int, int, int, int)’’ for more information.

Syntax

void fit_to_width(int flag);

Remark

Table 5-3 lists the fit_to_width(int) method setting descriptions.

Table 5-3: fit_to_width(int) Method Settings  

Setting

Description

0

Method is off.

1

Method is on.

_________________________________________________________________________

Example

myPanel1.zoom = 0;
myPanel1.Simage.fit_to_width(1);
myPanel1.repaint();

_________________________________________________________________________

getBitsPerPixel(void)

This method returns the bit depth of the image. See Appendix D for more information on the number of bits per pixel of your image.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int getBitsPerPixel();

Returns

Integer. Any positive value (as well as 0) is a valid return.

get_fit_to_height()

This method returns the value set by fit_to_height(int).

Syntax

int get_fit_to_height();

Returns

Integer. It returns a 0 if off or 1 if on.

get_fit_to_width()

This method returns the value set by fit_to_width(int).

Syntax

int get_fit_to_width();

Returns

Integer. It returns a 0 if off or 1 if on.

getHeight(void)

This method returns the height of the image in pixels.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int getHeight();

Returns

Integer. Any positive value (as well as 0) is a valid return.

getInitialZoom(int, int)

This method calculates the first zoom increment given the image’s height and width. Sometimes images are smaller than the containers in which they display. In that case, the image fits into the container either by height or width. The zoom increment is simply the ratio of screen pixels to image pixels.

For example, if this method returns 35, two zoom operations with a normal zoom increment of 25 are required before the image is noticeably zoomed.

Notes:
For the first zoom operation on an image, assuming the scrollbars are off, always zoom the image by at least the amount returned from this method.
A negative value indicates an error. See Appendix H for more information.
The getInitialZoom(int, int) method is based on the width and height of the panel. Scrolling will not work unless the image fills the entire panel.

Syntax

int getInitialZoom(int xsize, int ysize);

Remark

Table 5-4 lists the getInitialZoom(int, int) method variable descriptions.

Table 5-4: getInitialZoom(int, int) Method Variables

Variable

Description

xsize

Panel width in pixels.

ysize

Panel height in pixels.

getWidth(void)

This method returns the width of the image in pixels.

Syntax

int getWidth();

Returns

Integer. Any positive value (as well as 0) is a valid return.

getXdpi(void)

This method returns the X resolution, in dpi (dots per inch), of the image.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int getXdpi();

Returns

Integer. Any positive value (as well as 0) is a valid return.

getYdpi(void)

This method returns the Y resolution, in dpi (dots per inch), of the image.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int getYdpi();

Returns

Integer. Any positive value (as well as 0) is a valid return.

IMG_antique_effect(void)

This method converts color images to look as though they are antique photos. It replaces colors with sepia tones, which are reddish brown monochrome tints. When applied to a photo, they give the picture a warm, antique feeling.

Note:
This method only works with 24-bit color images.

Syntax

int IMG_antique_effect();

IMG_autocrop_bitmap(int, int)

This function finds and clips any white border around the image in all directions. The border is discarded and the image is resized to the new cropped rectangle plus the margin.

The margin may be a value of 0.

Notes:
This function only works with 1-bit images. If you use this function with an image that is not a 1-bit image, you will get a PIXEL_DEPTH_UNSUPPORTED (-21) error message. See Appendix H for more information.
A negative value indicates an error. See the imgerr.h file or Appendix H for more information.

 

Syntax

int SNBDAPI IMG_autocrop_bitmap(int hdib, int margin);

Remark

Table 5-5 lists the IMG_autocrop_bitmap(int, int) method variable descriptions.

Table 5-5: IMG_autocrop_bitmap(int, int) Function Variables

Variable

Description

hdib

Standard RasterMaster image handle.

margin

Number of pixels to add to the autocrop rectangle.

Returns

Integer. Any positive value (as well as 0) is a valid return.

IMG_auto_orient(Snow.Snowbnd, int)

This function returns the orientation of the image. The value is 90 or 0. If the value is 90, you may want to fix the image by using IMG_rotate_bitmap() as follows:

IMG_auto_orient(imghandle,angle)
if (angle == 90)
IMG_rotate_bitmap(imghandle,andle[0] * 100)

 See ‘‘IMG_rotate_bitmap(int)’’ for more information.

Note:
A negative value indicates an error. See the imgerr.h file or Appendix H for more information.

Syntax

int SNBDAPI IMG_auto_orient(Snowbnd hdib, int *p_angle);

Remark

Table 5-6 lists the IMG_auto_orient(Snow.Snowbnd, int) method variable descriptions.

Table 5-6: IMG_auto_orient(Snow.Snowbnd, int) Function Variables

Variable

Description

hdib

Standard RasterMaster image object.

p_angle

p_angle Angle returned as the current orientation. Either 90 or 0 is returned.

Returns

Integer. Any positive value (as well as 0) is a valid return.

IMG_color_gray(void)

This method converts 24-bit color images to 8-bit gray scale images.

Note:
This method only works with 24-bit images.

Syntax

int IMG_color_gray();

IMG_create_thumbnail(int, int)

This method intelligently resizes down images. It supports any pixel depth and chooses IMG_resize_bicubic for color images or IMG_resize_to_gray for 1-bit black and white images. This method is excellent for creating thumbnails.

Syntax

int IMG_create_thumbnail(int xsize, int ysize);

Remark

Table 5-7 lists the IMG_create_thumbnail(int, int) method variable descriptions.

Table 5-7: IMG_create_thumbnail(int, int) Method Variables

Variable

Description

xsize

Destination width of image after resizing.

ysize

Destination height of image after resizing.

IMG_decompress_bitmap(String, int)

This method decompresses an image from the local disk. This standard method can be used by applications, signed applets, or applets for which disk read permissions have been granted. As with all decompression methods, it automatically detects the file format.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_decompress_bitmap(String st, int page);

Remark

Table 5-8 lists the IMG_decompress_bitmap(String, int) method variable descriptions.

Table 5-8: IMG_decompress_bitmap(String, int) Method Variables

Variable

Description

st

Path and filename of the image to decompress.

page

Page number for the multipage image file.

Returns

Integer. Any positive value (as well as 0) is a valid return.

_________________________________________________________________________

Example

FileDialog fd = new FileDialog(this,"Open " +      "Bitmap",FileDialog.LOAD);
fd.show();
FileName = fd.getDirectory() + fd.getFile();
if (FileName != null)
{
      tSimage = new Snow.Snowbnd();
      tSimage.IMG_decompress_bitmap(FileName,0);
}
____
_____________________________________________________________________

IMG_decompress_bitmap(java.awt.Image, int)

This method imports a Java™ image object.

Note:
A negative value indicates an error. See Appendix H for more information.

 

Syntax

int IMG_decompress_bitmap(java.awt.Image img, int bits_pix);

Remark

Table 5-9 lists the IMG_decompress_bitmap(java.awt.Image, int) method variable descriptions.

Table 5-9: IMG_decompress_bitmap(java.awt.Image, int) Method Variables

Variable

Description

img

Java Image object from which to import data.

bits_pix

Destination bits per pixel desired. Data from Java image objects is returned as 24 bits, but you can convert to 1-bit or 8-bit if desired. For color, use 24-bits.

Returns

Integer. Any positive value (as well as 0) is a valid return.

_________________________________________________________________________

Example

java.awt.Image img;
int xsize, ysize;

if (myPanel1.Simage == null && myPanel1.Sann == null) return;

xsize = myPanel1.Simage.getWidth();
ysize = myPanel1.Simage.getHeight();
img = this.createImage(xsize,ysize);
Graphics g = img.getGraphics();
myPanel1.Simage.IMG_decompress_bitmap(img,1);
myPanel1.Simage.IMG_display_bitmap(g,0,0,xsize,ysize);
myPanel1.Sann = null;
myPanel1.repaint(),

_________________________________________________________________________

IMG_decompress_bitmap(java.io.DataInputStream, int)

This method decompresses data from a DataInputStream and automatically detects the file format. It only decompresses an image from a DataInputStream and created from a ByteArray. Then, you can call decompress on a ByteArray or create a DataInputStream from this ByteArray.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_decompress_bitmap(java.io.DataInputStream di, int page);

Remark

Table 5-10 lists the IMG_decompress_bitmap(java.io.DataInputStream, int) method variable descriptions.

Table 5-10: IMG_decompress_bitmap(java.io.DataInputStream, int) Method Variables

Variable

Description

di

Java.io.DataInputStream.

page

Page number if reading from multipage image file.

Returns

Integer. Any positive value (as well as 0) is a valid return.

_________________________________________________________________________

Example

java.io.RandomAccessFile ras;
int length;
byte buff[];
try
{
      
ras = new java.io.RandomAccessFile (st,"r");
      
length = (int)ras.length();
      
buff = new byte[length];
      
ras.readFully(buff,0,length);
}
catch (IOException ioe)
{
      
return -2;
}
java.io.DataInputStream di;
di = new java.io.DataInputStream(new java.io.ByteArrayInputStream(buff))
stat = tSimage.IMG_decompress_bitmap(di, page);

_________________________________________________________________________

IMG_decompress_bitmap_fd(String, int, int)

This method works the same as IMG_decompress_bitmap but can be used for image formats that are embedded in a larger file and do not start at the beginning of a file.

Syntax

int IMG_decompress_bitmap_fd(String bm_name, int offset, int page);

Note:
A negative value indicates an error. See Appendix H for more information.

Remark

Table 5-11 lists the IMG_decompress_bitmap_fd(String, int, int) method variable descriptions.

Table 5-11: IMG_decompress_bitmap_fd(String, int, int) Method Variables  

Variable

Description

bm_name

File name of image to decompress.

offset

Offset of start of image format in bytes.

page

Image or page number to decompress if multipage file format. Set to 0 for first page.

Returns

Integer. Any positive value (as well as 0) is a valid return.

IMG_decompress_bitmap_stream(String, int)

This method reads images from a standard URL. This method automatically detects the file format and is normally used by applets.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_decompress_bitmap_stream(String st, int page);

Remark

Table 5-12 lists the IMG_decompress_bitmap_stream(String, int) method variable descriptions.

Table 5-12: IMG_decompress_bitmap_stream(String, int) Method Variables  

Variable

Description

st

URL and filename of the image to decompress, for example, http://www.snowbound.com/image.tif.

page

Page number for multipage file.

Returns

Integer. Any positive value (as well as 0) is a valid return.

IMG_decompress_bitmap_stream_onthefly(String, int, java.awt.Container)

This method decompresses and displays partially downloaded image data from a URL. The image begins to display even before all image data is downloaded.

This special method is used by applets. As with all decompression methods, it automatically detects the file format.

Notes:
 
A display container is required for this method.
  
This method should not be used when there are no Graphical User Interface classes.
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_decompress_bitmap_stream_onthefly(String st, int page, java.awt.Container sf);

Remark

Table 5-13 lists the IMG_decompress_bitmap_stream_onthefly(String, int, java.awt.Container) method variable descriptions.

Table 5-13: IMG_decompress_bitmap_stream_onthefly(String, int, java.awt.Container) Method Variables  

Variable

Description

st

URL and file name of image to decompress, for example, http://www.snowbound.com/image.tif.

page

Page number for multipage files.

Container sf

Container which can get the panel or frame where the application or applet resides.

Returns

Integer. Any positive value (as well as 0) is a valid return.

IMG_decompress_fax(java.lang.String, int, int, int, int, int)

This method decompresses compressed fax data from proprietary image file formats which use the CCITT G3 or G4 compression algorithms. The path name is the absolute path to the file.

The developer is responsible for reading any header information such as height, width, fill order, or compression. Call this function to decompress the data and convert it into a Snow.DIB in memory.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_decompress_fax(String bm_name, int xsize, int ysize, int type, int fill_order, int offset);

Remark

Table 5-14 lists the IMG_decompress_fax(java.lang.String, int, int, int, int, int) method variable descriptions.

Table 5-14: IMG_decompress_fax(java.lang.String, int, int, int, int, int) Method Variables

Variable

Description

bm_name

Absolute path and file name to the file on the local file system.

xsize

Width, in pixels, of the image after decompression.

ysize

Height, in pixels, of the image after decompression.

type

2 = Group 3 2d image.
3 = Group 3.
4 = Group 4 fax.

fill_order

Bit order in each byte. Normal values:
0 = CALS, Intel byte order (MSB -> LSB).
2 = G3 and G4, Motorola byte order (LSB -> MSB).

offset

Absolute position of the first byte of compressed data.

Returns

Integer

IMG_decompress_fax(java.io.DataInputStream, int, int, int, int, int)

This method decompresses fax or proprietary image formats which use the CCITT G3 or G4 compression algorithms.

The developer is responsible for reading any header information such as height, width, fill order, or compression. Call this function to decompress the data and convert it into a Snow.DIB in memory.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_decompress_fax(java.io.DataInputStream di, int xsize, int ysize, int type, int fill_order, int offset);

Remark

Table 5-15 lists the IMG_decompress_fax(java.io.DataInputStream, int, int, int, int, int) method variable descriptions.

Table 5-15: IMG_decompress_fax(java.io.DataInputStream, int, int, int, int, int) Method Variables

Variable

Description

di

DataInputStream containing compressed file data.

xsize

Width, in pixels, of the image after decompression.

ysize

Height, in pixels, of the image after decompression.

type

2 = Group 3 2d image.
3 = Group 3.
4 = Group 4 fax.

fill_order

Bit order in each byte. Normal values:
0 = CALS, Intel byte order (MSB -> LSB).
2 = G3 and G4, Motorola byte order (LSB -> MSB).

offset

Absolute position of the first byte of compressed data.

Returns

Integer

IMG_decompress_multipage_bitmap_stream_onthefly(String, int, java.awt.Container)

This method decompresses and displays partially downloaded image data from a URL. The image begins to display even before all image data is downloaded. After the first page is decompressed and downloaded, the other pages of a multipage file are downloaded in the background. This allows subsequent pages to be available faster.

This special method is used by applets. As with all decompression methods, it automatically detects the file format.

Notes: 
A display container is required for this method.
This method should not be used when there are no Graphical User Interface classes.
 
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_decompress_multipage_bitmap_stream_onthefly(String st, int page, java.awt.Container sf);

Remark

Table 5-16 lists the IMG_decompress_multipage_bitmap_stream_onthefly(String, int, java.awt.Container) method variable descriptions.

Table 5-16: IMG_decompress_multipage_bitmap_stream_onthefly(String, int, java.awt.Container) Method Variables  

Variable

Description

st

URL and file name of image to decompress, for example, http://www.snowbound.com/image.tif.

page

Page number for multipage files.

Container sf

Container which can get the panel or frame where the application or applet resides.

Returns

Integer. Any positive value (as well as 0) is a valid return.

IMG_deskew_bitmap(int)

This method is a fast rotate for 1-bit skewed images. Use this method after IMG_get_deskew_angle returns a skew angle. This method rotates only from -45 to 45 degrees, but is much faster than IMG_rotate_bitmap for 1-bit images. For best results, use values of -20 to 20.

See ‘‘IMG_get_bitmap_block(int, int, int, int)’’ and ‘‘IMG_rotate_bitmap(int)’’ for more information.

Notes:
When a call is made to IMG_deskew_bitmap, the internal Snowbound image object is stored in memory for viewing. The function needs to be saved to the library for the change to be permanent.
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_deskew_bitmap(int rot_angle);

Remark

Table 5-17 lists the IMG_deskew_bitmap(int) method variable descriptions.

Table 5-17: IMG_deskew_bitmap(int) Method Variables

Variable

Description

rot_angle

Angle to rotate image.

Returns

Integer. Any positive value (as well as 0) is a valid return.

IMG_despeckel_bitmap(int)

This method removes noise (random pixel data) from 1-bit images. This method works only with 1-bit images. The quality variable can accept a range of 100 values.

Notes:
When a call is made to IMG_despeckel_bitmap, the internal Snowbound image object is stored in memory for viewing. The function needs to be saved to the library for the change to be permanent.
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_despeckel_bitmap(int quality);

Remark

Table 5-18 lists the IMG_despeckel_bitmap(int) method setting descriptions.

Table 5-18: IMG_despeckel_bitmap(int) Method Settings

Setting

Description

1

Minimum noise reduction.

30

Normal noise reduction.

100

Maximum noise reduction.

Returns

Integer. Any positive value (as well as 0) is a valid return.

IMG_diffusion_mono(void)

This method converts 4, 8, or 24 bit images to 1-bit per pixel bi-level images.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_diffusion_mono();

Returns

Integer. Any positive value (as well as 0) is a valid return.

IMG_display_bitmap(java.awt.Graphics, int, int, int, int)

This method displays the current image at the current X and Y coordinates, and is not corrected for aspect ratio. To use RasterMaster’s automatic aspect ratio correction during display, use IMG_display_bitmap_aspect.

See ‘‘IMG_display_bitmap_aspect(java.awt.Graphics, java.awt.Container, int, int, int, int, int)’’ for more information.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_display_bitmap(Graphics g, int xpos, int ypos, int xsize, int ysize);

Remark

Table 5-19 lists the IMG_display_bitmap(java.awt.Graphics, int, int, int, int) method variable descriptions.

Table 5-19: IMG_display_bitmap(java.awt.Graphics, int, int, int, int) Method Variables  

Variable

Description

g

Graphics context.

xpos

Starting X position for drawing the image.

ypos

Starting Y position for drawing the image.

xsize

Horizontal size of displayed image.

ysize

Vertical size of displayed image.

Returns

Integer. Any positive value (as well as 0) is a valid return.

IMG_display_bitmap_aspect(java.awt.Graphics, java.awt.Container, int, int, int, int, int)

This method displays the current image, corrected for aspect ratio, at the current X and Y coordinates. It also displays scroll bars if the image is zoomed (zoom != 0 and zoom > Snowbnd.getInitialZoom()).

RasterMaster automatically detects whether or not Swing is present, and uses the correct scroll bar for AWT or Swing.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_display_bitmap_aspect(Graphics g, Container f, int xpos, int ypos, int xsize, int ysize, int zoom);

Remark

Table 5-20 lists the IMG_display_bitmap_aspect(java.awt.Graphics, java.awt.Container, int, int, int, int, int) method variable descriptions.

Table 5-20: IMG_display_bitmap_aspect(java.awt.Graphics, java.awt.Container, int, int, int, int, int) Method Variables

Variable

Description

g

Graphics context.

f

Current java.awt.Container for image.

xpos

Starting X position for drawing the image.

ypos

Starting Y position for drawing the image.

xsize

Horizontal size of displayed image.

ysize

Vertical size of displayed image.

zoom

Zoom factor.
0 = Display entire image.
100 = One-to-one pixel display (one pixel per screen).

Returns

Integer. Any positive value (as well as 0) is a valid return.

_________________________________________________________________________

Example

public void paint (Graphics g)
{
      
if (Simage != null)
      
{
      
in = getInsets();
         
/* NOTE THAT Microsoft JVIEW.EXE has a bug and does not
         
start the origin at 0,0 under the title bar. Comment this
         
next line to fix Jview.exe. All other Java Machines work
         
fine.*/
      
g.translate(in.left, in.top);

            
d = getSize();
            
d.width = (in.right + in.left);
            
d.height = (in.top + in.bottom);

      
if (cropped == 0)
            
stat =
             
Simage.IMG_display_bitmap_aspect(g, this,
               
0,0,d.width,d.height, zoom);
         
else

            
Simage.IMG_display_bitmap(g,0,0,d.width,d.height);
      
if (select)
            
snbd_draw_pen();
      
}
}

_________________________________________________________________________

IMG_display_bitmap_smooth(java.awt.Graphics, java.awt.Container, int, int, int, int, int)

This method displays the current image, corrected for aspect ratio, at the current X and Y coordinates. The zoom value is a percentage of the image display to the container size. A value of zero will fill the current container with a best fit, either fit to width or fit to height. For example, a value of 10 will zoom the image 10% larger than the container size. This will crop the image slightly. A negative value will shrink the image by the percentage and center in the container.  

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_display_bitmap_smooth(Graphics hdc, Container sf, int xs, int ys, int xsize, int ysize, int zoom);

Remark

Table 5-21 lists the IMG_display_bitmap_smooth(java.awt.Graphics, java.awt.Container, int, int, int, int, int) method variable descriptions.

Table 5-21: IMG_display_bitmap_smooth(java.awt.Graphics, java.awt.Container, int, int, int, int, int) Method Variables

Variable

Description

hdc

Graphics port to draw into.

sf

Container to draw into.

xs

Starting X coordinate of container.

ys

Starting Y coordinate of container.

xsize

Xsize coordinate of container.

ysize

Ysize coordinate of container.

zoom

Zoom level.

Returns

Integer. Any positive value (as well as 0) is a valid return.

_________________________________________________________________________

Example

public void paint (Graphics g)
{
      
if (Simage != null)
      
{
d = getSize();
in = getInsets();
d.width -= (in.right + in.left);
d.height -= (in.top + in.bottom);

 

      in = getInsets();
         
/* NOTE THAT Microsoft JVIEW.EXE has a bug and does not
         
start the origin at 0,0 under the title bar. Comment this
         
next line to fix Jview.exe. All other JVMs work
         
fine.*/
      
g.translate(in.left, in.top);

            
stat = Simage.IMG_display_bitmap_smooth(g, this, 0, 0, d.width,  
d.height,zoom);
}
}
public void update(Graphics g)
{
// If the container is showing, be sure to repaint it, otherwise
// repainting it is unnecessary and will cause update flashing
if ((Simage == null) || (Simage.dis_crop_xe == Simage.dis_width)
|| (Simage.dis_crop_ye == Simage.dis_height))
{
g.setColor(getBackground());
g.fillRect(0, 0, d.width, d.height);
g.setColor(getForeground());
}

     paint(g);

}

_________________________________________________________________________

IMG_erase_rect(int, int, int, int, int, int, int)

This method fills the inside or outside of the specified rectangle (xs, ys, xsize, and ysize parameters) with the color passed in. It can be used to remove borders, for instance.

For 24-bit images, the color value must be a RGB-packed pixel; 1 byte red, 1 byte green, and 1 byte blue. For 1-bit black and white images, only the least significant bit is used.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_erase_rect(int xs, int ys, int xsize, int ysize, int color, int in_outflag, int operation);

Remark

Table 5-22 lists the IMG_erase_rect(int, int, int, int, int, int, int) method variable descriptions.

Table 5-22: IMG_erase_rect(int, int, int, int, int, int, int) Method Variables

Variable

Description

xs

Start X coordinate of rectangle in pixels.

ys

Start Y coordinate of rectangle in pixels.

xsize

Width of rectangle in pixels.

ysize

Height of rectangle in pixels.

color

Color to fill.

in_outflag

1 = fill inside rectangle.
0 = fill outside rectangle to the borders of the image.

operation

1 = xor image rectangle.
0 = fill image.

Returns

Integer. Any positive value (as well as 0) is a valid return.

_________________________________________________________________________

Example

if (ssb.Simage != null)
{
      
int width = ssb.Simage.getWidth();
      
int height = ssb.Simage.getHeight();
   
         
ssb.Simage.IMG_erase_rect(width / 20, height / 20,
         
width (width / 10), height (height / 10),0xffffffff,
         
0, 0);
}
repaint();

_________________________________________________________________________

IMG_fill_bitmap_pattern(int, int, int, int, int, int, int, int, byte[])

This method allows filling an area of a bitmap with specified patterns found in the pattern argument.

Syntax

int IMG_fill_bitmap_pattern(int xs, int ys, int xsize, int ysize, int pattern_width, int pattern_height, int x_offset, int y_offset, int byte pattern[]);

Remark

Table 5-23 lists the IMG_fill_bitmap_pattern(int, int, int, int, int, int, int, int, byte[]) method variable descriptions.

Table 5-23: IMG_fill_bitmap_pattern(int, int, int, int, int, int, int, int, byte[]) Method Variables  

Variable

Description

xs

Start X position of image to fill.

ys

Start Y position of image to fill.

xsize

Width of pattern area to fill.

ysize

Height of pattern area to fill.

pattern_width

Width of data in pattern array.

pattern_height

Height of data in pattern array.

x_offset

X offset of data in pattern array.

y_offset

Y offset of data in pattern array.

byte pattern []

Array of pattern data bytes.

IMG_flip_bitmapx(void)

This method flips the image horizontally to produce a mirror image. Positive X coordinates along the X-axis are swapped with negative X coordinates, and vice versa.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_flip_bitmapx();

Returns

Integer. Any positive value (as well as 0) is a valid return.

IMG_flip_bitmapy(void)

This method flips the image vertically to produce a mirror image. Positive Y coordinates along the Y-axis are swapped with negative Y coordinates, and vice versa.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_flip_bitmapy();

Returns

Integer. Any positive value (as well as 0) is a valid return.

IMG_get_bitmap_block(int, int, int, int)

This method returns a block of data from the current image and creates a Snowbnd object, where the data is specified by the rectangle constructed from the image’s coordinates. The image can then be displayed, rotated, saved, and more.

Syntax

Snow.Snowbnd IMG_get_bitmap_block(int xs, int ys, int xsize, int ysize);

Remark

Table 5-24 lists the Snow.Snowbnd IMG_get_bitmap_block(int, int, int, int) method variable descriptions.

Table 5-24: Snow.Snowbnd IMG_get_bitmap_block(int, int, int, int) Method Variables

Variable

Description

xs

Starting X position for the image block.

ys

Starting Y position for the image block.

xsize

Horizontal size of the image block in pixels.

ysize

Vertical size of the image block in pixels.

Returns

A new Snowbnd object

IMG_get_deskew_angle(int[], int, int)

This method returns the skew angle for 1-bit images. When scanning multiple pages, images are often slightly skewed or rotated. The values returned in the p_angle[] array should be passed to IMG_deskew_bitmap.

See ‘‘IMG_deskew_bitmap(int)’’ for more information.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_get_deskew_angle(int p_angle[], int start_angle, int end_angle);

Remark

Table 5-25 lists the IMG_get_deskew_angle(int[], int, int) method variable descriptions.

Table 5-25: IMG_get_deskew_angle(int[], int, int) Method Variables

Variable

Description

p_angle

Integer array to return the rotation or skew angle; this array can have a single element.

start_angle

Minimum angle to start (no less than -45 degrees; -20 is optimum.

end_angle

Maximum angle to test for (no more than 45 degrees; 20 is optimum).

Returns

Integer. Any positive value (as well as 0) is a valid return.

_________________________________________________________________________

Example

if (Simage != null)
      
stat =
         
Simage.IMG_get_deskew_angle(pangle, -15, 15);

if (stat >= 0 && pangle[0] != 0)
{
      
Simage.IMG_deskew_bitmap(pangle[0]);
      
repaint();
}

_________________________________________________________________________

IMG_invert_bitmap(void)

This method inverts the current image, changing pixels by a simple XOR operation applied to each byte of the image in memory. For bi-level images, this method changes black to white and white to black.

Note:
A negative value indicates an error. See Appendix H for more information.

Syntax

int IMG_invert_bitmap(void);

Returns

Integer. Any positive value (as well as 0) is a valid return.

IMG_merge_block(Snow.Snowbnd, int, int, int)

This method draws a source image on top of the current image at the x and y coordin