Victor Library Function Reference



addimage

      8   24 

Function Prototypes
Visual BasicDeclare Function addimage Lib "VIC32.DLL" (srcimg As imgdes, oprimg As imgdes, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.addimage Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef oprimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.addimage(ref imgdes srcimg, ref imgdes oprimg, ref imgdes resimg);
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




addnoise

      8   24 

Function Prototypes
Visual BasicDeclare Function addnoise Lib "VIC32.DLL" (ByVal amount As Long, srcimg As imgdes, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.addnoise Lib "VIC32.DLL" (ByVal amount As Integer, ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.addnoise(int amount, ref imgdes srcimg, ref imgdes resimg);
C/C++int addnoise(int amount, imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.addnoise(int amount, imgdes srcimg, imgdes resimg);

Function Arguments
amount Amount of noise to add (0 to 255)
srcimg Source image
resimg Result image

Description

The addnoise function adds random noise to the image by replacing pixel intensity values with random values between 0 and 255. The amount of noise specified determines how much noise is added. A value of 255 results in complete replacement of the image pixel values with noise. Any value lower that 255 results in proportionately fewer pixels being replaced.

Result pixel 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




addtext

  1    8   24 

Function Prototypes
Visual BasicDeclare Function addtext Lib "VIC32.DLL" (ByVal color As long, ByVal pointsize, As long, ByVal font As String, ByVal text As String, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.addtext Lib "VIC32.DLL" (ByVal color As Integer, ByVal pointsize As Integer, ByVal font As String, ByVal text As String, ByRef resimg As imgdes) As Integer
C#int vicwin.addtext(int color, int pointsize, string font, string text, ref imgdes resimg);
C/C++int addtext(unsigned int color, int pointsize, LPCSTR font, LPCSTR text, imgdes *resimg);
Javaint vic.vic32jni.addtext(int color, int pointsize, String font, String text, imgdes resimg);

Function Arguments
colorRGB color value for text
pointsizeHeight of text, in points
fontName of the font to use
textText to put into the image
resimgResult image

Description

The addtext function places text within an image area. The color is specified by the formula:

where blu, grn, and red range from 0 - 255. Alternatively, use the Windows RGB function to assemble the color value.

The pointsize is specified as a multiple of 1/72 inch. Body text on a printed page is generally set at 10 pt, while a headline could be 20 pt.

For example, to add text that is red and 34-pt in the Verdana typeface:

	rcode = addtext(255, 34, "Verdana", "This is a text string", myimage);

Internally the addtext function uses the following definition of logical font:

   LOGFONT lf = { 0, 0, 0, 
	  0, 700, 0, 0, 0,
      0, 0, 0, 0, 0, "ARIAL"
      };

For more information about the LOGFONT structure see an introductory Windows GDI textbook.

The image area is defined by the image descriptor.

Return value




addtextex

  1    8   24 

Function Prototypes
Visual BasicDeclare Function addtextex Lib "VIC32.DLL" (ByVal color As long, ByRef lfont As LOGFONT, ByVal text As String, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.addtextex Lib "VIC32.DLL" (ByVal color As Integer, ByRef lfont As LOGFONT, ByVal text As String, ByRef resimg As imgdes) As Integer
C#int vicwin.addtextex(int color, ref LOGFONT lfont, string text, ref imgdes resimg);
C/C++int addtextex(unsigned int color, LOGFONT * lfont, LPCSTR text, imgdes *resimg);
Javaint vic.vic32jni.addtextex(int color, LOGFONT lfont, String text, imgdes resimg);

Function Arguments
colorRGB color value for text
lfontVariable of type LOGFONT describing the text font
textText to put into the image
resimgResult image

Description

The addtextex function places text within an image area. This function is mainly for use with C/C++ programming. Modern programming languages can use the more direct dot Net drawtext function.

The color is specified by the formula:

where blu, grn, and red range from 0 - 255. Alternatively, use the Windows RGB function to assemble the color value.

The LOGFONT structure elements are defined as follows:
lfHeightpointsize
lfWidthwidth
lfEscapementrotation of the line of text
lfOrientationrotation of each character
lfWeightboldness
lfItalicitalics
lfUnderlineunderline
lfStrikeOutstrikeout
lfCharSetcharacter set
lfOutPrecisionmatching precision
lfClipPrecisionclipping method
lfQualityantialiasing
lfPitchAndFamilyfont family
lfFaceNamefont name

For more information about the LOGFONT structure see an introductory Windows GDI textbook.

The image area is defined by the image descriptor.

Return value




addtexture

      8   24 

Function Prototypes
Visual BasicDeclare Function addtexture Lib "VICFX.DLL" (srcimg As imgdes, oprimg As imgdes, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.addtexture Lib "VICFX.DLL" (ByRef srcimg As imgdes, ByRef oprimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.addtexture(ref imgdes srcimg, ref imgdes oprimg, ref imgdes resimg);
C/C++int addtexture(imgdes *srcimg, imgdes *oprimg, imgdes *resimg);
Javaint vic.vic32jni.addtexture(imgdes srcimg,imgdes oprimg, imgdes resimg);

Function Arguments
srcimg Source image
oprimg Operator image
resimg Result image

Description

The addtexture 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, subtracts 128, and places the sum in the result image area. Result values greater than 255 are set to 255. Result values less than zero are set to zero.

The image areas are defined by the corresponding image descriptors. Download the combine images module vicfx.

Import library for MSVC: vicfx.lib

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
VB.NETDeclare Function allocDIB Lib "VIC32.DLL" (ByRef image As imgdes, ByVal width As Integer, ByVal length As Integer, ByVal vbitcount As Integer) As Integer
C#int vicwin.allocDIB(ref imgdes image, int width, int length, int vbitcount);
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   32 

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
VB.NETDeclare Function vicwin.allocimage Lib "VIC32.DLL" (ByRef image As imgdes, ByVal width As Integer, ByVal length As Integer, ByVal vbitcount As Integer) As Integer
C#int vicwin.allocimage(ref imgdes image, int width, int length, int vbitcount);
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, 24, or 32)

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. The allocimage function creates a DIB section and the DIB components are not necessarily in adjacent memory blocks. This means that allocimage should not be used to create a DIB that will be passed to the clipboard--use allocDIB instead.

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
VB.NETDeclare Function vicwin.andimage Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef oprimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.andimage(ref imgdes srcimg, ref imgdes oprimg, ref imgdes resimg);
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

bleachimage

      8   24 

Function Prototypes
Visual BasicDeclare Function bleachimage Lib "VICFX.DLL" (srcimg As imgdes, oprimg As imgdes, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.bleachimage Lib "VICFX.DLL" (ByRef srcimg As imgdes, ByRef oprimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.bleachimage(ref imgdes srcimg, ref imgdes oprimg, ref imgdes resimg);
C/C++int bleachimage(imgdes *srcimg, imgdes *oprimg, imgdes *resimg);
Javaint vic.vic32jni.bleachimage(imgdes srcimg,imgdes oprimg, imgdes resimg);

Function Arguments
srcimg Source image
oprimg Operator image
resimg Result image

Description

The bleachimage function combines the brightness level of each pixel in the source image area with the brightness level of the corresponding pixel in the operator image area to create an interesting visual effect. Result values greater than 255 are set to 255. Result values less than zero are set to zero.

The image areas are defined by the corresponding image descriptors. Download the combine images module vicfx.

Import library for MSVC: vicfx.lib

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
VB.NETDeclare Function vicwin.blur Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.blur(ref imgdes srcimg, ref imgdes resimg);
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
VB.NETDeclare Function vicwin.blurthresh Lib "VIC32.DLL" (ByVal threshold As Integer, ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.blurthresh(int threshold, ref imgdes srcimg, ref imgdes resimg);
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
VB.NETDeclare Function vicwin.bmpinfo Lib "VIC32.DLL" (ByVal filename As String, ByRef bminfo As BITMAPINFOHEADER) As Integer
C#int vicwin.bmpinfo(string filename, ref BITMAPINFOHEADER bminfo);
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
VB.NETDeclare Function vicwin.bmpinfofrombuffer Lib "VIC32.DLL" (ByVal buff As Integer, ByRef bminfo As BITMAPINFOHEADER) As Integer
C#int vicwin.bmpinfofrombuffer(ref int buff, ref BITMAPINFOHEADER bminfo);
C/C++int bmpinfofrombuffer(UCHAR *buff,BITMAPINFOHEADER *bminfo);
Javaint vic.vic32jni.bmpinfofrombuffe(int buff, BITMAPINFOHEADER bminfo);
viclib64
C#int vicwin.bmpinfofrombuffer(System.IntPtr buff, ref 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
VB.NETDeclare Function vicwin.brightenmidrange Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.brightenmidrange(ref imgdes srcimg, ref imgdes resimg);
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
VB.NETDeclare Function vicwin.calcavglevel Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef redavg As Integer, ByRef grnavg As Integer, ByRef bluavg As Integer) As Integer
C#int vicwin.calcavglevel(ref imgdes image, ref int redavg, ref int grnavg, ref int bluavg);
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++




calcavglevelfloat

      8   24 

Function Prototypes
Visual BasicDeclare Function calcavglevelfloat Lib "VICSTATS.DLL" (srcimg As imgdes, redavg As Double, grnavg As Double, bluavg As Double) As Long
VB.NETDeclare Function vicwin.calcavglevelfloat Lib "VICSTATS.DLL" (ByRef srcimg As imgdes, ByRef redavg As Double, ByRef grnavg As Double, ByRef bluavg As Double) As Integer
C#int vicwin.calcavglevelfloat(ref imgdes image, ref double redavg, ref double grnavg, ref double bluavg);
C/C++int calcavglevelfloat(imgdes *image, double *redavg, double *grnavg, double *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 calcavglevelfloat function calculates the average value of the pixels in an image area as a double precision floating point number. 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. Download the analysis module vicstats.

Import library for MSVC: vicstats.lib

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
VB.NETDeclare Function vicwin.calchisto Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef redtable As Integer, ByRef grntable As Integer, ByRef blutable As Integer) As Integer
C#int vicwin.calchisto(ref imgdes image, ref int redtable, ref int grntable, ref int blutable);
C/C++int calchisto(imgdes *image, long *redtable, long *grntable, long *blutable);
Javaint vic.vic32jni.calchisto(imgdes image, int[] redtable, int[] grntable, int[] blutable);
viclib64
C#int vicwin.calchisto(ref 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
VB.NETDeclare Function vicwin.calchistorgb Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef redtable As Integer, ByRef grntable As Integer, ByRef blutable As Integer, ByVal mode As Integer) As Integer
C#int vicwin.calchistorgb(ref imgdes image, ref int redtable, ref int grntable, ref int blutable, int histoMode);
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);
viclib64
C#int vicwin.calchistorgb(ref 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++




calcminmax

      8   16   24   32 

Function Prototypes
Visual BasicDeclare Function calcminmax Lib "vic32.dll" (srcimg As imgdes, redMinmax As MINMAX, grnMinmax As MINMAX, bluMinmax As MINMAX) As Long
VB.NETDeclare Function vicwin.calcminmax Lib "vic32.dll" (ByVal srcimg As imgdes, ByRef redMinmax As minmax, ByRef grnMinmax As minmax, ByRef bluMinmax As minmax) As Integer
C#int vicwin.calcminmax(ref imgdes srcimg, ref MINMAX redMinmax, ref MINMAX grnMinmax, ref MINMAX bluMinmax);
C/C++int calcminmax(imgdes *srcimg, MINMAX *redMinmax, MINMAX *grnMinmax, MINMAX *bluMinmax);
Javaint vic.vic32jni.calcminmax(imgdes srcimg, MINMAX redMinmax, MINMAX grnMinmax, MINMAX bluMinmax);

Function Arguments
srcimg Source image
redMinmax Variable of type MINMAX to receive the minimum and maximum pixel data for an grayscale image,
or red data for a color image
grnMinmax Variable of type MINMAX to receive green data
bluMinmax Variable of type MINMAX to receive blue data

Description

The calcminmax function determines the minimum and maximum pixel values in an image area. The value are returned in the data structure MINMAX. The image area is defined by the image descriptor.

The MINMAX structure elements are defined as follows:
minMinimum pixel value
max Maximum pixel value
res1 Reserved
res2 Reserved

For an 8-, 16-, or 32-bit grayscale image, the min and max data are placed in redMinmax. For an 8- or 24-bit color image, the red, green, and blue values are placed in redMinmax, grnMinmax, and bluMinmax, respectively. To determine the min and max absolute pixel values for an 8-bit palette color image, set the image descriptor element imgtype to 1 before calling calcminmax.

Return value

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
VB.NETDeclare Function vicwin.changebright Lib "VIC32.DLL" (ByVal amount As Integer, ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.changebright(int amount, ref imgdes srcimg, ref imgdes resimg);
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
VB.NETDeclare Function vicwin.clienttoimage Lib "VIC32.DLL" (ByVal hWnd As Integer, ByRef resimg As imgdes) As Integer
C#int vicwin.clienttoimage(int hWnd, ref imgdes resimg);
C/C++int clienttoimage(HWND hWnd, imgdes *resimg);
Javaint vic.vic32jni.clienttoimage(int hWnd, imgdes resimg);
viclib64
C#int vicwin.clienttoimage(System.IntPtr hWnd, ref 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++




cmykimagetorgbimage

         32 

Function Prototypes
Visual BasicDeclare Function cmykimagetorgbimage Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.cmykimagetorgbimage Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.cmykimagetorgbimage(ref imgdes srcimg, ref imgdes resimg);
C/C++int cmykimagetorgbimage(imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.cmykimagetorgbimage(imgdes srcimg, imgdes resimg);

Function Arguments
srcimg Source image
resimg Result image

Description The cmykimagetorgbimage function converts a cyan, magenta, yellow, black (CMYK) image area to a red, green, blue (RGB) image area. This function and the rgbimagetocmykimage function are used to convert between the RGB and CMYK color models. The source and result image areas are defined by the corresponding image descriptors.

The source image must be 32-bit and the result image must be 24-bit.

For more information about a color models, see any introductory graphics textbook.

Return value




colordither

      8   24 

Function Prototypes
Visual BasicDeclare Function colordither Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes, ByVal palmode As Long) As Long
VB.NETDeclare Function vicwin.colordither Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef resimg As imgdes, ByVal palmode As Integer) As Integer
C#int vicwin.colordither(ref imgdes srcimg, ref imgdes resimg, int palmode);
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
VB.NETDeclare Function vicwin.colorscatter Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef resimg As imgdes, ByVal palmode As Integer) As Integer
C#int vicwin.colorscatter(ref imgdes srcimg, ref imgdes resimg, int palmode);
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
VB.NETDeclare Function vicwin.colortogray Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.colortogray(ref imgdes srcimg, ref imgdes resimg);
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
VB.NETDeclare Function vicwin.convert1bitto8bit Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.convert1bitto8bit(ref imgdes srcimg, ref imgdes resimg);
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
VB.NETDeclare Function vicwin.convert1bitto8bitsmooth Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.convert1bitto8bitsmooth(ref imgdes srcimg, ref imgdes resimg);
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
VB.NETDeclare Function vicwin.convert8bitto1bit Lib "VIC32.DLL" (ByVal conmode As Integer, ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.convert8bitto1bit(int conmode, ref imgdes srcimg, ref imgdes resimg);
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++




convert8bitto1bitex

      8   24 

Function Prototypes
Visual BasicDeclare Function convert8bitto1bitex Lib "VIC32.DLL" (ByVal conmode As Long, srcimg As imgdes, resimg As imgdes, ByRef dithermatrix_firstelem As byte) As Long
VB.NETDeclare Function vicwin.convert8bitto1bitex Lib "VIC32.DLL" (ByVal conmode As Integer, ByRef srcimg As imgdes, ByRef resimg As imgdes, ByRef dithermatrix_firstelem As byte) As Integer
C#int vicwin.convert8bitto1bitex(int conmode, ref imgdes srcimg, ref imgdes resimg, ref byte dithermatrix_firstelem);
C/C++int convert8bitto1bitex(int conmode, imgdes *srcimg, imgdes *resimg, UCHAR *dithermatrix);
Javaint vic.vic32jni.convert8bitto1bitex(int conmode, imgdes srcimg, imgdes resimg, byte [] dithermatrix);

Function Arguments
conmodeConversion mode (0-3)
srcimg Source image
resimg Result image
dithermatrixA 64-byte array of dither values (0 - 255)

Description

The convert8bitto1bitex 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 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
3 Ordered dither using the dithermatrix parameter


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. The ordered dither with the supplied dithermatrix provides complete control over the dithering. For example, set the entire dither matrix equal to 150 for a threshold of 150. For a halftone effect, try
2436713119525175139203
163 335991711143107
11551191471235927155
2271798321123618791219
2407914320723171135199
1751547111167 739103
12863311591195523151
2551919522124718387215

Return value




convertgray8to16

                8     

Function Prototypes
Visual BasicDeclare Function convertgray8to16 Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.convertgray8to16 Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.convertgray8to16(ref imgdes srcimg, ref imgdes resimg);
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" (ByVal min As Long, ByVal max As Long, srcimg As imgdes, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.convertgray16to8 Lib "VIC32.DLL" (ByVal min As Long, ByVal max As Long, ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.convertgray16to8(int min, int max, ref imgdes srcimg, ref imgdes resimg);
C/C++int convertgray16to8(int min, int max, imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.convertgray16to8(int min, int max, imgdes srcimg, imgdes resimg);

Function Arguments
min Low end of pixel values to expand (0-255)
max High end of pixel values to expand (0-255)
srcimg Source image, 16-bit grayscale
resimg Result image, 8-bit grayscale

Description
The convertgray16to8 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++

convertgray16to8ex

                16 

Function Prototypes
Visual BasicDeclare Function convertgray16to8ex Lib "VIC32.DLL" (ByVal min As Long, ByVal max As Long, srcimg As imgdes, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.convertgray16to8ex Lib "VIC32.DLL" (ByVal min As Integer, ByVal max As Integer, ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.convertgray16to8ex(int min, int max, ref imgdes srcimg, ref imgdes resimg);
C/C++int convertgray16to8ex(unsigned long min, unsigned long max, imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.convertgray16to8ex(int min, int max, imgdes srcimg, imgdes resimg);

Function Arguments
min Low end of pixel values to expand (0-65535)
max High end of pixel values to expand (0-65535)
srcimg Source image, 16-bitgrayscale
resimg Result image, 8-bit grayscale

Description
The convertgray16to8ex function converts a grayscale 16-bit per pixel source image area into a grayscale 8-bit per pixel result image area. The min and max value provide for quick inclusion of an expandcontrast function. This is useful for viewing a 10- or 12-bit image that's stored as a 16-bit data.

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

Return value




convertgray32to8

                32 

Function Prototypes
Visual BasicDeclare Function convertgray32to8 Lib "VIC32.DLL" (ByVal min As Long, ByVal max As Long, srcimg As imgdes, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.convertgray32to8 Lib "VIC32.DLL" (ByVal min As Integer, ByVal max As Integer, ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.convertgray32to8(int min, int max, ref imgdes srcimg, ref imgdes resimg);
C/C++int convertgray32to8(unsigned long min, unsigned long max, imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.convertgray32to8(int min, int max, imgdes srcimg, imgdes resimg);

Function Arguments
min Low end of pixel values to expand (0-65535)
max High end of pixel values to expand (0-65535)
srcimg Source image, 16-bitgrayscale
resimg Result image, 8-bit grayscale

Description
The convertgray32to8 function converts a grayscale 32-bit per pixel source image area into a grayscale 8-bit per pixel result image area. The min and max value provide for quick inclusion of an expandcontrast function. To prevent any expansion of contrast set min to zero and max to -1.

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

Return value




convertgray32to16

                32 

Function Prototypes
Visual BasicDeclare Function convertgray32to16 Lib "VIC32.DLL" (ByVal min As Long, ByVal max As Long, srcimg As imgdes, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.convertgray32to16 Lib "VIC32.DLL" (ByVal min As Integer, ByVal max As Integer, ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.convertgray32to16(int min, int max, ref imgdes srcimg, ref imgdes resimg);
C/C++int convertgray32to16(unsigned long min, unsigned long max, imgdes *srcimg, imgdes *resimg);
Javaint vic.vic32jni.convertgray32to16(int min, int max, imgdes srcimg, imgdes resimg);

Function Arguments
min Low end of pixel values to expand (0-65535)
max High end of pixel values to expand (0-65535)
srcimg Source image, 32-bitgrayscale
resimg Result image, 16-bit grayscale

Description
The convertgray32to16 function converts a grayscale 32-bit per pixel source image area into a grayscale 8-bit per pixel result image area. The min and max value provide for quick inclusion of an expandcontrast function. To prevent any expansion of contrast set min to zero and max to -1.

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

Return value





convertpaltorgb

      8 

Function Prototypes
Visual BasicDeclare Function convertpaltorgb Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.convertpaltorgb Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.convertpaltorgb(ref imgdes srcimg, ref imgdes resimg);
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
VB.NETDeclare Function vicwin.convertrgbtopal Lib "VIC32.DLL" (ByVal palcolors As Integer, ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.convertrgbtopal(int palcolors, ref imgdes srcimg, ref imgdes resimg);
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
VB.NETDeclare Function vicwin.convertrgbtopalex Lib "VIC32.DLL" (ByVal palcolors As Integer, ByRef srcimg As imgdes, ByRef resimg As imgdes, ByVal colredmode As Integer) As Integer
C#int vicwin.convertrgbtopalex(int palcolors, ref imgdes srcimg, ref imgdes resimg, int colredmode);
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++




correlateimages

      8    24 

Function Prototypes
Visual Basic Declare Function correlateimages Lib "VICSTATS.DLL" (srcimg As imgdes, oprimg As imgdes, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.correlateimages Lib "VICSTATS.DLL" (ByRef srcimg As imgdes, ByRef oprimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.correlateimages(ref imgdes srcimg, ref imgdes oprimg, ref imgdes resimg);
C/C++int correlateimages(imgdes *srcimg, imgdes *oprimg, imgdes *resimg);

Function Arguments
srcimg Source image
oprimg Operator image
resimg Result image

Description

The correlateimages function calculates the correlation coefficient between the operator image area and the source image area at every pixel position in the source area and places the scaled coefficient data in the result image. This is very useful for finding an embedded mark in a test image.

The pixel values can range from zero (negative correlation) through 128 (no correlation) up to 255 (perfect positive correlation). A negative correlation would mean a good match with the negative image of a reference mark. The brightest pixel in the result image represents the most probable location of the reference mark.

The image areas are defined by the corresponding image descriptors. Let the source image hold the larger image to be tested and let the operator image hold the reference mark. The operator image area must not be larger than the source image area. Download the analysis module vicstats.

Import library for MSVC: vicstats.lib

Return value

See also

correlationcoef

VB and C/C++ Examples Pattern Recognition, find a mark in an image.




correlationcoef

      8   24 

Function Prototypes
Visual BasicDeclare Function correlationcoef Lib "VICSTATS.DLL" (srcimg As imgdes, oprimg As imgdes, coefficient As Double) As Long
VB.NETDeclare Function vicwin.correlationcoef Lib "VICSTATS.DLL" (ByRef srcimg As imgdes, ByRef oprimg As imgdes, ByRef coefficient As Double) As Integer
C#int vicwin.correlationcoef(ref imgdes srcimg, ref imgdes oprimg, ref double coefficient);
C/C++int correlationcoef(imgdes *srcimg, imgdes *oprimg,double *coefficient);

Function Arguments
image Source image
oprimg Operator image
coefficient Variable to receive correlation coefficient

Description

The correlationcoef function calculates the correlation coefficient between two image areas as a double precision floating point number. The image areas are defined by the image descriptors.

The coorelation coefficient values can range from -1.0 (negative correlation) through 0 (no correlation) up to 1.0 (perfect positive correlation). Download the analysis module vicstats.

Import library for MSVC: vicstats.lib

Return value




correlationcoefRGB

      8   24 

Function Prototypes
Visual BasicDeclare Function correlationcoefRGB Lib "VICSTATS.DLL" (srcimg As imgdes, oprimg As imgdes, redcoefficient As Double, grncoefficient As Double, blucoefficient As Double) As Long
VB.NETDeclare Function vicwin.correlationcoefRGB Lib "VICSTATS.DLL" (ByRef srcimg As imgdes, ByRef oprimg As imgdes, ByRef redcoefficient As Double, ByRef grncoefficient As Double, ByRef blucoefficient As Double) As Integer
C#int vicwin.correlationcoef(ref imgdes srcimg, ref imgdes oprimg, ref double redcoefficient, ref double grncoefficient, ref double blucoefficient);
C/C++int _export WINAPI correlationcoefRGB(imgdes *srcimg, imgdes *oprimg, double *redcoefficient, double *grncoefficient, double *blucoefficient);

Function Arguments
image Source image
oprimg Operator image
redcoefficient Variable to receive red correlation coefficient
grncoefficient Variable to receive green correlation coefficient
blucoefficient Variable to receive blue correlation coefficient

Description

The correlationcoefRGB function calculates the correlation coefficient between two image areas as a double precision floating point number. The image areas are defined by the image descriptors.

The coorelation coefficient values can range from -1.0 (negative correlation) through 0 (no correlation) up to 1.0 (perfect positive correlation). Download the analysis module vicstats.

Import library for MSVC: vicstats.lib

Return value



copyimage

  1    8   24 

Function Prototypes
Visual BasicDeclare Function copyimage Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long
VB.NETDeclare Function vicwin.copyimage Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.copyimage(ref imgdes srcimg, ref imgdes resimg);
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
VB.NETDeclare Function vicwin.copyimagebits Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.copyimagebits(ref imgdes srcimg, ref imgdes resimg);
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
VB.NETDeclare Sub copyimagepalette Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef resimg As imgdes)
C#int vicwin.copyimagepalette(ref imgdes srcimg, ref imgdes resimg);
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
VB.NETDeclare Sub copyimgdes Lib "VIC32.DLL" (ByRef srcimg As imgdes, ByRef resimg As imgdes)
C#int vicwin.copyimgdes(ref imgdes srcimg, ref imgdes resimg);
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
VB.NETDeclare Function vicwin.cover Lib "VIC32.DLL" (ByVal thresh As Integer, ByRef srcimg As imgdes, ByRef oprimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.cover(int thresh, ref imgdes srcimg, ref imgdes oprimg, ref imgdes resimg);
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
VB.NETDeclare Function vicwin.coverclear Lib "VIC32.DLL" (ByVal transColor As Integer, ByRef srcimg As imgdes, ByRef oprimg As imgdes, ByRef resimg As imgdes) As Integer
C#int vicwin.coverclear(int transColor, ref imgdes srcimg, ref imgdes oprimg, ref imgdes resimg);
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