Victor Library Reference



Introduction

This Library Reference contains an entry for each function in the Victor Library. The function prototypes are shown for C/C++, Java, and Visual Basic. The function arguments and explanations are listed. And a description of the operation, return codes, and sample use of each function is given. The functions are listed alphabetically.

Image Pixel Depth

At the top of each function entry the numbers in the tinted boxes indicate the pixel depth of image that the function can operate on: 1-, 8-, 16-, or 24-bits per pixel. For example, addimage (first of the function descriptions) can operate on an 8- or 24-bit per pixel image.

For loadfile functions the boxed numbers describe the pixel depth of the image the file is loaded into and not the file pixel depth. If boxed numbers are not displayed the function operation is independent of image bits per pixel.




addimage

      8   24 

Function Prototypes
Visual BasicDeclare Function addimage Lib "VIC32.DLL" (srcimg As imgdes, oprimg As imgdes, resimg As imgdes) As Long
C/C++int addimage(imgdes *srcimg, imgdes *oprimg, imgdes *resimg);
Javaint vic.vic32jni.addimage(imgdes srcimg, imgdes oprimg, imgdes resimg);

Function Arguments
srcimg Source image
oprimg Operator image
resimg Result image

Description

The addimage function adds the brightness level of each pixel in the source image area to the brightness level of the corresponding pixel in the operator image area and places the sum in the result image area. Result values greater than 255 are set to 255.

The image areas are defined by the corresponding image descriptors.

Return value

Example C/C++ | Example VB




allocDIB

  1    8   16   24 

Function Prototypes
Visual BasicDeclare Function allocDIB Lib "VIC32.DLL" (image As imgdes, ByVal width As Long, ByVal length As Long, ByVal vbitcount As Long) As Long
C/C++int allocDIB(imgdes *image, int width, int length, int vbitcount);
Javaint vic.vic32jni.allocDIB(imgdes image, int width, int length, int vbitcount);

Function Arguments
image Image
width Image buffer width
length Image buffer length
vbitcount Bits per pixel (1, 8, 16, or 24)

Description

The allocDIB function allocates space for an image in contiguous global memory as a packed device independent bitmap (DIB). The memory allocated is sufficient to hold the BITMAPINFOHEADER header, palette, and image data of the DIB. The width, length, and vbitcount parameters determine the amount of memory allocated.

AllocDIB is similar to allocimage, but allocDIB allocates memory that is guaranteed contiguous, that is, the DIB components (BITMAPINFO struct and image data) are in adjacent memory blocks. This is a packed DIB and is compatible with the Windows clipboard CF_DIB format.

Allocimage, on the other hand, allocates memory that may not be contiguous -- the DIB components are not necessarily in adjacent memory blocks. If you are creating an image to pass to the clipboard, use allocDIB, otherwise, use allocimage.

If successful, allocDIB fills in the image descriptor and BITMAPINFOHEADER fields. The allocDIB function always sets the image descriptor element hBitmap to zero. For details, see allocimage.

The source code for allocDIB is included with the library in the module VICCORE.C. In the 16-bit library allocDIB is defined as allocimage.

Return value

See also

allocimage

Example C/C++




allocimage

  1    8   16   24 

Function Prototypes
Visual BasicDeclare Function allocimage Lib "VIC32.DLL" (image As imgdes, ByVal width As Long, ByVal length As Long, ByVal vbitcount As Long) As Long
C/C++int allocimage(imgdes *image, int width, int length, int vbitcount);
Javaint vic.vic32jni.allocimage(imgdes image, int width, int length, int vbitcount);

Function Arguments
image Image
width Image buffer width
length Image buffer length
vbitcount Bits per pixel (1, 8, 16, or 24)

Description

The allocimage function allocates space for an image as a DIB. The memory allocated is sufficient to hold the BITMAPINFOHEADER header, palette, and image data of the DIB. The width, length, and vbitcount parameters determine the amount of memory allocated.

The size of the palette area is dependent upon the vbitcount parameter. As shown below, the palette_size variable equals the amount of memory in bytes allocated for the palette data.



If successful, the allocimage function fills the following image descriptor fields:

Allocimage also fills the BITMAPINFOHEADER fields:

Allocimage initializes the palette to grayscale for an 8-bit image, and black and white for a 1-bit image.

An image allocated with allocimage must be released with freeimage when no longer needed to free memory used by the image.

If allocimage is called with vbitcount equal to 4, an 8-bit image buffer is allocated. This is to simplify loading a 4-bit BMP file.

If allocimage is called with vbitcount equal to 16, a 16-bit grayscale image buffer is allocated.

The source code for allocimage is included with the library in the module VICCORE.C.

There are some subtle differences between the allocimage functions as implemented in the 16- and 32-bit libraries that are worth noting:

Return value

See also

allocDIB

Example 1 C/C++ | Example VB

Example 2 C/C++




andimage

  1    8   24 

Function Prototypes
Visual BasicDeclare Function andimage Lib "VIC32.DLL" (srcimg As imgdes, oprimg As imgdes, resimg As imgdes) As Long
C/C++int andimage(imgdes *srcimg, imgdes *oprimg, imgdes *resimg);
Javaint vic.vic32jni.andimage(imgdes srcimg, imgdes oprimg, imgdes resimg);

Function Arguments
srcimg Source image
oprimg Operator image
resimg Result image

Description
The andimage function ANDs the value of each pixel in the source image area with the value of the corresponding pixel in the operator image area and places the result in the result image area.

The image areas are defined by the corresponding image descriptors.

Return value

Example C/C++ | Example VB




blur

      8   24 

Function Prototypes
Visual BasicDeclare Function blur Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
C/C++int blur(imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.blur(imgdes srcimg, imgdes resimg);

Function Arguments
srcimg Source image
resimg Result image

Description

The blur function softens the appearance of an image area by averaging 9 neighboring pixels to produce a smoothed image with softened edges.

The image areas are defined by the corresponding image descriptors.

Return value

Example C/C++ | Example VB




blurthresh

      8   24 

Function Prototypes
Visual BasicDeclare Function blurthresh Lib "VIC32.DLL" (ByVal threshold As Long, srcimg As imgdes, resimg As imgdes) As Long
C/C++int blurthresh(int threshold, imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.blurthresh(int threshold, imgdes srcimg, imgdes resimg);

Function Arguments
threshold Threshold value (0-255)
srcimg Source image
resimg Result image

Description

The blurthresh function is similar to the blur routine in that it softens the appearance of an image area, but also uses a threshold value which allows smoothing without degrading the edges of the image. If a pixel's brightness value differs from its neighbors' average value by greater than the threshold amount, it will not be changed. So, a threshold of 0 produces no blurring, while 255 is equivalent to using the blur function. The threshold value determines the amount of smoothing that occurs.

The source and result image areas are defined by the corresponding image descriptors.

Return value

See also

blur

Example C/C++ | Example VB




bmpinfo

Function Prototypes
Visual BasicDeclare Function bmpinfo Lib "VIC32.DLL" (ByVal filename As String, ByRef bminfo As BITMAPINFOHEADER) As Long
C/C++int bmpinfo(LPCSTR filename, BITMAPINFOHEADER *bminfo);
Javaint vic.vic32jni.bmpinfo(String filename, BITMAPINFOHEADER bminfo);

Function Arguments
filename Filename to read
bminfo Variable of type BITMAPINFOHEADER to receive the data

Description

The bmpinfo function reads the header of a BMP file and places the information in the bminfo structure. The purpose of the bmpinfo function is to identify the type and size of the image in the file to permit allocating enough memory to load the file.The BITMAPINFOHEADER structure is defined in the file WINDOWS.H and is shown below.

The BITMAPINFOHEADER structure elements are defined as follows:
biSize Size of this struct
biWidth Image width in pixels
biHeight Image height in pixels
biPlanes Planes = 1
biBitCount Color bits per pixel 1, 4, 8, 24
biCompression Compression type
biSizeImage Image size in bytes
biXPelsPerMeter Horizontal resolution
biYPelsPerMeter Vertical resolution
biClrUsed Number of colors used
biClrImportant Number of important colors

The BMP file contains a BITMAPFILEHEADER followed by a device independent bitmap (DIB) consisting of a BITMAPINFO structure and an array of bytes defining the pixels of the bitmap. For more information, see loadbmp.

Return value

See also

loadbmp, savebmp

Example C/C++ | Example VB




bmpinfofrombuffer


Function Prototypes
Visual BasicDeclare Function bmpinfofrombuffer Lib "VIC32.DLL" (ByVal buff As Long, ByRef bminfo As BITMAPINFOHEADER) As Long
C/C++int bmpinfofrombuffer(UCHAR *buff, BITMAPINFOHEADER *bminfo);
Javaint vic.vic32jni.bmpinfofrombuffe(int buff, BITMAPINFOHEADER bminfo);

Function Arguments
buff Buffer address
bminfo Variable of type BITMAPINFOHEADER to receive the data

Description
The bmpinfofrombuffer function reads the header information from memory holding BMP file data and places the image information in the bminfo structure. The purpose of the bmpinfofrombuffer function is to identify the type and size of the image and permit allocating enough memory to load the file.

The BITMAPINFOHEADER structure elements are defined as follows:
biSize Size of this struct
width Image width in pixels
biSize Size of this struct
biWidth Image width in pixels
biHeight Image height in pixels
biPlanes Planes = 1
biBitCount Color bits per pixel 1, 4, 8, 24
biCompression Compression type
biSizeImage Image size in bytes
biXPelsPerMeter Horizontal resolution
biYPelsPerMeter Vertical resolution
biClrUsed Number of colors used
biClrImportant Number of important colors

The BMP file data contains a BITMAPFILEHEADER followed by a device independent bitmap (DIB) consisting of a BITMAPINFO structure and an array of bytes defining the pixels of the bitmap.

Return value    Explanation
NO_ERROR Function successful
BAD_OPN Memory handle not available
BAD_BMP File is not a readable BMP format
BAD_PTR Buff points at unreadable memory

See also bmpinfo

Example C/C++




brightenmidrange

      8   24 

Function Prototypes
Visual BasicDeclare Function brightenmidrange Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
C/C++int brightenmidrange(imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.brightenmidrange(imgdes srcimg, imgdes resimg);

Function Arguments
srcimg Source image
resimg Result image

The brightenmidrange function brightens the intermediate brightness levels within an image area. The source and result image areas are defined by the corresponding image descriptors. The brightenmidrange function is useful in brightening an image before printing.

Return value

Example C/C++ | Example VB




calcavglevel

      8   24 

Function Prototypes
Visual BasicDeclare Function calcavglevel Lib "VIC32.DLL" (srcimg As imgdes, redavg As Long, grnavg As Long, bluavg As Long) As Long
C/C++int calcavglevel(imgdes *image, int *redavg, int *grnavg, int *bluavg);
Javaint vic.vic32jni.calcavglevel(imgdes srcimg, refvar redavg, refvar grnavg, refvar bluavg);

Function Arguments
image Source image
redavg Average level for an grayscale image,
or average red level for a color image
grnavg Average green level
bluavg Average blue level

Description

The calcavglevel function calculates the average value of the pixels in an image area. The image area is defined by the image descriptor.

For an 8-bit grayscale image, the average level is placed in redavg. For an 8- or 24-bit color image, the average red, green, and blue values are placed in redavg, grnavg, and bluavg, respectively.

Return value

Example C/C++




calchisto

      8   24 

Function Prototypes
Visual BasicDeclare Function calchisto Lib "VIC32.DLL" (image As imgdes, redtable As Long, grntable As Long, blutable As Long) As Long
C/C++int calchisto(imgdes *image, long *redtable, long *grntable, long *blutable);
Javaint vic.vic32jni.calchisto(imgdes image, int[] redtable, int[] grntable, int[] blutable);

Function Arguments
image Source image
redtable Buffer to receive histogram data for an 8-bit image
or red histogram data for a 24-bit image
grntable Buffer to receive green histogram data (24-bit only)
blutable Buffer to receive blue histogram data (24-bit only)

Description

The calchisto function calculates histogram data for an image area. The image area is defined by the image descriptor. The function counts the number of pixels at level 0 through level 255, and places the data in an array of 256 long integers.

For 8-bit images only the redtable buffer is filled. For 24-bit images data is placed into redtable, grntable, and blutable. Note that each array used must be capable of holding 256 long integers.

Return value

See also

calchistorgb

Example C/C++




calchistorgb

      8   24 

Function Prototypes
Visual BasicDeclare Function calchistorgb Lib "VIC32.DLL" (image As imgdes, redtable As Long, grntable As Long, blutable As Long, ByVal histoMode As Long) As Long
C/C++int calchistorgb(imgdes *image, long *redtable, long *grntable, long *blutable, int histoMode);
Javaint vic.vic32jni.calchistorgb(imgdes image, int[] redtable, int[] grntable, int[] blutable, int histoMode);

Function Arguments
image Source image
redtable Buffer to receive histogram data for an 8-bit image
or red histogram data for a 24-bit image
grntable Buffer to receive green histogram data (24-bit only)
blutable Buffer to receive blue histogram data (24-bit only)
histoMode Mode
0 = interpret palette color image as gray
1 = interpret palette color image as RGB

Description

The calchistorgb function calculates histogram data for an image area. The image area is defined by the image descriptor. The function counts the number of pixels at level 0 through level 255, and places the data in an array of 256 long integers.

The histogram data is stored in one table (redtable) or three tables (redtable, grntable, and blutable). A grayscale image fills one table and a 24-bit RGB image fills three tables. A color palette image fills one or three tables depending on histoMode. If histoMode is zero, a palette color image is interpreted as a grayscale image and one table is filled. If histoMode is nonzero, a palette color image is interpreted as a 24-bit RGB image and three tables are filled. This is summarized below. Note that each array used must be capable of holding 256 long integers.

Table 4. Calchistorgb Characteristics
Image Type histoMode Histogram tables filled
8-bit grayscale 0 redtable
1 redtable
8-bit palette color 0 redtable
1 redtable, grntable, blutable
24-bit RGB 0 redtable, grntable, blutable
1 redtable, grntable, blutable

If histoMode is zero, calchistorgb is equivalent to calchisto. To set histoMode, two constants have been defined:

Return value

See also

calchisto

Example C/C++




changebright

      8   24 

Function Prototypes
Visual BasicDeclare Function changebright Lib "VIC32.DLL" (ByVal amount As Long, srcimg As imgdes, resimg As imgdes) As Long
C/C++int changebright(int amount, imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.changebright(int amount, imgdes srcimg, imgdes resimg);

Function Arguments
amount Amount to change (-255 to 255)
srcimg Source image
resimg Result image

Description

The changebright function increases or decreases the brightness level of each pixel in the source image area by the specified amount and places the result in the result image area.

Result brightness values less than 0 are set to 0 and values greater than 255 are set to 255. The source and result image areas are defined by the corresponding image descriptors.

Return value

Example C/C++ | Example VB


clienttoimage

            1    8   24 

Function Prototypes
Visual BasicDeclare Function clienttoimage Lib "VIC32.DLL" (ByVal hWnd As Long, resimg As imgdes) As Long
C/C++int clienttoimage(HWND hWnd, imgdes *resimg);
Javaint vic.vic32jni.clienttoimage(int hWnd, imgdes resimg);

Function Arguments
hWnd Window handle
resimg Result image

Description
The clienttoimage function creates a Victor-compatible image from a window's client area. This function provides an easy way to capture the client area of a window displayed on the screen.

The result image will have the same bits per pixel as the current display mode. If the function is successful the image descriptor resimg is filled in. Clienttoimage allocates memory to hold the image, so freeimage must be called when this memory is no longer needed.

Return value    Explanation
NO_ERROR Function successful
BAD_MEM Insufficient memory
BAD_BPP Bits per pixel not 1, 4, 8, 16, or 24

See also
windowtoimage

Example C/C++




colordither

      8   24 

Function Prototypes
Visual BasicDeclare Function colordither Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes, ByVal palmode As Long) As Long
C/C++int colordither(imgdes *srcimg, imgdes *resimg, int palmode);
Javaint vic.vic32jni.colordither(imgdes srcimg, imgdes resimg, int palmode);

Function Arguments
srcimg Source image
resimg Result image
palmode zero = 16-color standard palette
nonzero = 256-color rainbow palette

Description

The colordither function converts an 8- or 24-bit color image area into an 8-bit palette color image area. The result image is a dither representation using either the Windows 16-color standard palette or a 256-color rainbow palette, depending on the value of the palmode argument.

This function provides a very quick and accurate method for displaying a color image on a video adapter limited to 16 or 256 colors.

The color palette that is created is stored at the location defined by the result image descriptor member palette and the image descriptor member colors is set to 16 or 256.

The colordither function uses the Victor defaultpalette function or the rainbowpalette function to create the 16- or 256-color palettes used by the function.

Return value

See also

convertrgbtopal, colorscatter

Example C/C++




colorscatter

      8   24 

Function Prototypes
Visual BasicDeclare Function colorscatter Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes, ByVal palmode As Long) As Long
C/C++int colorscatter(imgdes *srcimg, imgdes *resimg, int palmode);
Javaint vic.vic32jni.colorscatter(imgdes srcimg, imgdes resimg, int palmode);

Function Arguments
srcimg Source image
resimg Result image
palmode zero = 16-color standard palette
nonzero = 256-color rainbow palette

Description

The colorscatter function converts an 8- or 24-bit color image area into an 8-bit palette color image area. The result image is a scatter representation using either the Windows 16-color standard palette or a 256-color rainbow palette, depending on the value of the palmode argument.

This function provides a quick and accurate method for displaying a color image on a video adapter limited to 16 or 256 colors.

The color palette that is created is stored at the location defined by the result image descriptor member palette and the image descriptor member colors is set to 16 or 256. The colorscatter function uses the Victor defaultpalette function or the rainbowpalette function to create the 16-or 256-color palettes used by the function.

Return value

See also

convertrgbtopal, colordither

Example C/C++




colortogray

      8   24 

Function Prototypes
Visual BasicDeclare Function colortogray Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
C/C++int colortogray(imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.colortogray(imgdes srcimg, imgdes resimg);

Function Arguments
srcimg Color image, 8-bit or 24-bit
resimg Grayscale image, 8-bit

Description

The colortogray function converts an 8-bit or 24-bit color image area into an 8-bit grayscale image area. This function is used primarily to convert a color image to grayscale for printing. The source and result image areas are described by the corresponding image descriptors.

A grayscale palette is created and stored at the location defined by the result image descriptor member palette and colors is set to 256.

The grayscale intensity of a result pixel is based on red, green, and blue levels of the corresponding source pixel using the following formula:

gray = (30 * red + 59 * green + 11 * blue) / 100

The values 30, 59, and 11 represent the relative red, green, and blue intensities.

Return value

Example C/C++




convert1bitto8bit

  1 

Function Prototypes
Visual BasicDeclare Function convert1bitto8bit Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
C/C++int convert1bitto8bit(imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.convert1bitto8bit(imgdes srcimg, imgdes resimg);

Function Arguments
srcimg Source image, 1-bit
resimg Result image, 8-bit

Description

The convert1bitto8bit function converts a 1-bit per pixel source image area into an 8-bit per pixel result image area. The source and result image areas are defined by the corresponding image descriptors. This function is primarily used to convert a bilevel image to a grayscale image for subsequent image processing.

In the conversion a source pixel value of 1 is converted to a result pixel value of 255. A grayscale palette is created and stored at the location defined by the result image descriptor member palette and colors is set to 256. Bit 0 of the image descriptor member imgtype is set to 1.

Return value

See also

convert8bitto1bit

Example C/C++ | Example VB




convert1bitto8bitsmooth

  1 

Function Prototypes
Visual BasicDeclare Function convert1bitto8bitsmooth Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
C/C++int convert1bitto8bitsmooth(imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.convert1bitto8bitsmooth(imgdes srcimg, imgdes resimg);

Function Arguments
srcimg Source image, 1-bit
resimg Result image, 8-bit

Description

The convert1bitto8bitsmooth function converts a 1-bit per pixel source image area into an 8-bit per pixel result image area. The pixels are smoothed horizontally during the conversion. The source and result image areas are defined by the corresponding image descriptors.

This function is primarily used as a "scale to gray" method to convert a bilevel image to a grayscale image for subsequent improved appearance.

A grayscale palette is created and stored at the location defined by the result image descriptor member palette and colors is set to 256. Bit 0 of the image descriptor member imgtype is set to 1.

Return value

See also

convert1bitto8bit

Example C/C++




convert8bitto1bit

      8 

Function Prototypes
Visual BasicDeclare Function convert8bitto1bit Lib "VIC32.DLL" (ByVal conmode As Long, srcimg As imgdes, resimg As imgdes) As Long
C/C++int convert8bitto1bit(int conmode, imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.convert8bitto1bit(int conmode, imgdes srcimg, imgdes resimg);

Function Arguments
conmode Conversion mode (0-2)
srcimg Source image, 8-bit
resimg Result image, 1-bit

Description

The convert8bitto1bit function converts an 8-bit per pixel source image area into a 1-bit per pixel result image area. The source and result image areas are defined by the corresponding image descriptors.

This function is primarily used to convert a grayscale image to a bilevel image. If the source image is a palette color image, convert8bitto1bit produces a 1-bit image based on the grayscale intensity of the source image.

conmode Conversion technique
0 Scatter (error diffusion)
1 Ordered dither
2 Threshold


The scatter and dither conversion methods are very good for simulating gray levels in bilevel images. The threshold method converts pixels with gray levels below 128 to 0, and those above or equal to 128 to 1.

Return value

Example C/C++




convertgray8to16

                8     

Function Prototypes
Visual BasicDeclare Function convertgray8to16 Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
C/C++int convertgray8to16(imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.convertgray8to16(imgdes srcimg, imgdes resimg);

Function Arguments
srcimg Source image, 8-bit grayscale
resimg Result image, 16-bit grayscale

Description
The convertgray8to16 function converts a grayscale 8-bit per pixel source image area into a grayscale 16-bit per pixel result image area. The source and result image areas are defined by the corresponding image descriptors. A 16-bit grayscale image can be saved with savetif.

Return value

Example C/C++




convertgray16to8

                16 

Function Prototypes
Visual BasicDeclare Function convertgray16to8 Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
C/C++int convertgray16to8(imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.convertgray16to8(imgdes srcimg, imgdes resimg);

Function Arguments
srcimg Source image, 16-bit grayscale
resimg Result image, 8-bit grayscale

Description
The convert16to8 function converts a grayscale 16-bit per pixel source image area into a grayscale 8-bit per pixel result image area. The source and result image areas are defined by the corresponding image descriptors.

Return value

Example C/C++




convertpaltorgb

      8 

Function Prototypes
Visual BasicDeclare Function convertpaltorgb Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
C/C++int convertpaltorgb(imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.convertpaltorgb(imgdes srcimg, imgdes resimg);

Function Arguments
srcimg Source image, 8-bit palette color
resimg Result image, 24-bit RGB color

Description

The convertpaltorgb function converts an 8-bit palette color image area into a 24-bit RGB image area. For each pixel in the source image area, red, green, and blue pixels are calculated and placed in the result buffer.

This function can be used to convert a 256-color image to a 24-bit RGB image for subsequent color image processing.

Return value

Example C/C++




convertrgbtopal

         24 

Function Prototypes
Visual BasicDeclare Function convertrgbtopal Lib "VIC32.DLL" (ByVal palcolors As Long, srcimg As imgdes, resimg As imgdes) As Long
C/C++int convertrgbtopal(int palcolors, imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.convertrgbtopal(int palcolors, imgdes srcimg, imgdes resimg);

Function Arguments
palcolors Number of colors in result image (2-256)
srcimg Source image, 24-bit RGB color
resimg Result image, 8-bit color

Description

The convertrgbtopal function converts a 24-bit RGB image area into an 8-bit palette color image area. The color palette is stored at the location defined by the result image descriptor member palette and colors is set to palcolors.

This function calculates the palette color image using the median-cut algorithm and follows the scheme:

Convertrgbtopal uses a through-space-distance (TSD) method to assign palette colors to pixels. Diffusion scatter is not used (see convertrgbtopalex for additional information).

This function can be used to convert 24-bit RGB images into palette color images for display on 16- and 256-color display adapters.The time required to create the palette color image depends upon the size of the area and complexity of the source image.

Return value

See also

convertrgbtopalex, colordither, colorscatter

Example C/C++




convertrgbtopalex

         24 

Function Prototypes
Visual BasicDeclare Function convertrgbtopalex Lib "VIC32.DLL" (ByVal palcolors As Long, srcimg As imgdes, resimg As imgdes, ByVal colredmode As Long) As Long
C/C++int convertrgbtopalex(int palcolors, imgdes *srcimg, imgdes *resimg, int colredmode);
Javaint vic.vic32jni.convertrgbtopalex(int palcolors, imgdes srcimg, imgdes resimg, int colredmode);

Function Arguments
palcolors Number of colors in result image (2-256)
srcimg Source image, 24-bit RGB color
resimg Result image, 8-bit color
colredmode Color reduction mode to use

Description

The convertrgbtopalex function converts a 24-bit RGB image area into an 8-bit palette color image area. The color palette is stored at the location defined by the result image descriptor member palette and colors is set to palcolors.

This function calculates the palette color image using the median-cut algorithm and follows the scheme:

The colredmode parameter determines the mode to use to assign palette colors to pixels:
Table 5. Convertrgbtopalex Color Reduction Modes
Colredmode Speed Image quality Color matching method Use diffusion?
CR_OCTREENODIFF fastest good octree no
CR_OCTREEDIFF faster better octree yes
CR_TSDNODIFF1 faster better TSD2 no
CR_TSDDIFF fast best TSD2 yes

In general, there is a trade-off of speed for quality, mode CR_TSDDIFF gives the best color matching but takes the longest time.

Convertrgbtopalex can use either an octree or a through-space-distance (TSD) method for mapping a pixel to a palette color. The octree method uses an octree to select the palette color, while the TSD method calculates the minimum distance in 3-D RGB space to select the palette color. The TSD method provides a more accurate color match but also takes a little longer.

Convertrgbtopalex can also use error diffusion. Error diffusion creates a higher quality image by distributing a pixel's error to its nearest neighbors. Diffusion should not be used if an image is to be processed further, in this case use mode CR_TSDNODIFF or CR_OCTREENODIFF.

This function can be used to convert 24-bit RGB images into palette color images for display on 16- and 256-color display adapters.

Return value

See also

colordither, colorscatter

Example C/C++




copyimage

  1    8   24 

Function Prototypes
Visual BasicDeclare Function copyimage Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
C/C++int copyimage(imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.copyimage(imgdes srcimg, imgdes resimg);

Function Arguments
srcimg Source image
resimg Result image

Description

The copyimage function copies a source image area and palette to a result image area and palette. The source and result image areas and palette tables are defined by the corresponding image descriptors.

The copyimage function will work correctly, even if the source and result image areas overlap within the same buffer. If the source and result image areas are not the same size, the copyimage function will use the smaller of the two areas.

Return value

Example C/C++ | Example VB




copyimagebits

  1    8   24 

Function Prototypes
Visual BasicDeclare Function copyimagebits Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
C/C++int copyimagebits(imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.copyimagebits(imgdes srcimg, imgdes resimg);

Function Arguments
srcimg Source image
resimg Result image

Description

The copyimagebits function copies a source image area to a result image area. The source and result image areas are defined by the corresponding image descriptors. This function does not copy palette information. The copyimagebits function will work correctly, even if the source and result image areas overlap within the same buffer. If the source and result image areas are not of the same size, the copyimagebits function will use the smaller of the two areas.

Return value

Example C/C++




copyimagepalette

  1    8 

Function Prototypes
Visual BasicDeclare Function copyimagepalette Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
C/C++int copyimagepalette(imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.copyimagepalette(imgdes srcimg, imgdes resimg);

Function Arguments
srcimg Source image
resimg Result image

Description

The copyimagepalette function copies a source image palette to a result image palette. The source and result image palettes are defined by the corresponding image descriptors. The number of colors copied is determined by the source image descriptor member colors.

Return value

There is no return value.

Example C/C++




copyimgdes

Function Prototypes
Visual BasicDeclare Function copyimgdes Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
C/C++int copyimgdes(imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.copyimgdes(imgdes srcimg, imgdes resimg);

Function Arguments
srcimg Source image
resimg Result image

Description

The copyimgdes function copies all elements of a source image descriptor to a result image descriptor. Note that this function does not copy any image data, it only copies structure member data. Copyimgdes is equivalent to:

Return value

There is no return value.

Example C/C++ 1 | Example C/C++ 2 | Example VB




cover

      8   24 

Function Prototypes
Visual BasicDeclare Function cover Lib "VIC32.DLL" (ByVal thresh As Long, srcimg As imgdes, oprimg As imgdes, resimg As imgdes) As Long
C/C++int cover(int thresh, imgdes *srcimg, imgdes *oprimg, imgdes *resimg);
Javaint vic.vic32jni.cover(int thresh, imgdes srcimg, imgdes oprimg, imgdes resimg);

Function Arguments
thresh Threshold (0-255)
srcimg Source image
oprimg Operator image
resimg Result image

Description

The cover function places a bright section of the operator image onto the source image. The source image can be thought of as providing a backdrop for the operator image. It is in the darker regions of the operator that the source shows through. Cover uses a threshold to determine if a source pixel shows through. Any operator pixel having a brightness level less than the threshold is replaced by the source pixel in the result area. The resulting image consists of the bright pixels of the operator with the source providing the background.

For an RGB image the operator pixel value is calculated

The image areas are defined by the corresponding image descriptors.

Return value

Example C/C++ | Example VB




coverclear

                8   24 

Function Prototypes
Visual BasicDeclare Function coverclear Lib "VIC32.DLL" (ByVal transColorAs Long, srcimg As imgdes, oprimg As imgdes, resimg As imgdes) As Long
C/C++int coverclear(int transColor, imgdes *srcimg, imgdes *oprimg, imgdes *resimg);
Javaint vic.vic32jni.coverclear(int transColor, imgdes srcimg, imgdes oprimg, imgdes resimg);

Function Arguments
transColor Transparent color(0-0xffffff)
srcimg Source image
oprimg Operator image
resimg Result image

Description
The coverclear function places the operator image onto the source image. In regions of the operator where pixel values are equal to transcolor the source image will show through. The image areas are defined by the corresponding image descriptors.

Return value    Explanation
NO_ERROR Function successful
BAD_RANGE Range error, see Appendix A
BAD_IBUF Invalid image buffer address
BAD_MEM Insufficient memory
BAD_BPP Images are not both 8- or 24-bit
BAD_DIB Source or result is a compressed DIB
BAD_FAC Transcolor is outside the range 0 (black) to 0xffffff (white)

See also
cover

Example C/C++ | Example VB


next section