Victor Library Function Reference
addimage
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function addimage Lib "VIC32.DLL" (srcimg As imgdes, oprimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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.
-
Result = Source + Operator
The image areas are defined by the corresponding image descriptors.
Return value
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Images are not all 8- or 24-bit |
| BAD_DIB | One of the images is a compressed DIB |
addnoise
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function addnoise Lib "VIC32.DLL" (ByVal amount As Long, srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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.
-
if Random value 1 < amount
-
Result = Random value 2
-
Result = Source
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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Images are not both 8- or 24-bit |
| BAD_DIB | Source or result is a compressed DIB |
| BAD_FAC | Amount to add is outside the range 0 to 255 |
addtext
| 1 | 8 | 24 |
Function Prototypes
| Visual Basic | Declare 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.NET | Declare 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); |
| Java | int vic.vic32jni.addtext(int color, int pointsize, String font, String text, imgdes resimg); |
Function Arguments
| color | RGB color value for text |
| pointsize | Height of text, in points |
| font | Name of the font to use |
| text | Text to put into the image |
| resimg | Result image |
Description
The addtext function places text within an image area. The color is specified by the formula:
-
color = blu * 65536 + grn * 256 + red
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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Image is not 1-, 8-, or 24-bit |
| BAD_DIB | Image is a compressed DIB |
addtextex
| 1 | 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function addtextex Lib "VIC32.DLL" (ByVal color As long, ByRef lfont As LOGFONT, ByVal text As String, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int vic.vic32jni.addtextex(int color, LOGFONT lfont, String text, imgdes resimg); |
Function Arguments
| color | RGB color value for text |
| lfont | Variable of type LOGFONT describing the text font |
| text | Text to put into the image |
| resimg | Result 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:
-
color = blu * 65536 + grn * 256 + red
The LOGFONT structure elements are defined as follows:
| lfHeight | pointsize |
| lfWidth | width |
| lfEscapement | rotation of the line of text |
| lfOrientation | rotation of each character |
| lfWeight | boldness |
| lfItalic | italics |
| lfUnderline | underline |
| lfStrikeOut | strikeout |
| lfCharSet | character set |
| lfOutPrecision | matching precision |
| lfClipPrecision | clipping method |
| lfQuality | antialiasing |
| lfPitchAndFamily | font family |
| lfFaceName | font 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Image is not 1-, 8-, or 24-bit |
| BAD_DIB | Image is a compressed DIB |
addtexture
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function addtexture Lib "VICFX.DLL" (srcimg As imgdes, oprimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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.
-
Result = Source + Operator - 128
The image areas are defined by the corresponding image descriptors. Download the combine images module vicfx.
Import library for MSVC: vicfx.lib
Return value
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Images are not all 8- or 24-bit |
| BAD_DIB | One of the images is a compressed DIB |
allocDIB
| 1 | 8 | 16 | 24 |
Function Prototypes
| Visual Basic | Declare Function allocDIB Lib "VIC32.DLL" (image As imgdes, ByVal width As Long, ByVal length As Long, ByVal vbitcount As Long) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Width or length is zero |
| BAD_MEM | Insufficient global memory |
| BAD_BPP | Vbitcount is not 1, 4, 8, 16, or 24 |
See also
allocimage
allocimage
| 1 | 8 | 16 | 24 |
Function Prototypes
| Visual Basic | Declare Function allocimage Lib "VIC32.DLL" (image As imgdes, ByVal width As Long, ByVal length As Long, ByVal vbitcount As Long) As Long |
| VB.NET | Declare 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); |
| Java | int 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 vbitcount >= 16
-
palette_size = 0
-
palette_size = sizeof(RGBQUAD) * (1 << vbitcount)
If successful, the allocimage function fills the following image descriptor fields:
| ibuff | = image data address |
| stx | = 0 |
| sty | = 0 |
| endx | = width - 1 |
| endy | = length - 1 |
| buffwidth | = (width * vbitcount + 31) / 32 * 4) |
| palette | = palette data address |
| colors | = 1 << vbitcount for 1- or
8-bit image
= 0 for 16-, 24-, or 32-bit image |
| imgtype | = 1 for 1-, 8-, 16-, or 32-bit image
= 0 for 24-bit image |
| bmh | = bitmapinfoheader address |
| hBitmap | = device independent bitmap handle |
Allocimage also fills the BITMAPINFOHEADER fields:
| biSize | = BITMAPINFOHEADER size in bytes |
| biWidth | = width |
| biHeight | = length |
| biPlanes | = 1 |
| biBitCount | = vbitcount (1, 8, 16, 24, or 32) |
| biCompression | = BI_RGB (no compression) |
| biSizeImage | = buffwidth * length |
| biXPelsPerMeter | = 0 |
| biYPelsPerMeter | = 0 |
| biClrUsed | = 1 << vbitcount for 1-
or 8-bit image
= 0 for 16-, 24-, or 32-bit image |
| biClrImportant | = 1 << vbitcount
for 1- or 8-bit image
= 0 for 16-, 24-, or 32-bit image |
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
| NO_ERROR | Function successful |
| BAD_RANGE | Width or length is zero |
| BAD_MEM | Insufficient global memory |
| BAD_BPP | Vbitcount is not 1, 4, 8, 16, 24, or 32 |
See also
allocDIB
andimage
| 1 | 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function andimage Lib "VIC32.DLL" (srcimg As imgdes, oprimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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.
-
Result = Source & Operator
The image areas are defined by the corresponding image descriptors.
Return value
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Images are not all 1-, 8-, or 24-bit |
| BAD_DIB | One of the images is a compressed DIB |
bleachimage
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function bleachimage Lib "VICFX.DLL" (srcimg As imgdes, oprimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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.
-
Result = (255 - Source) * (255 - Operator) / 255
The image areas are defined by the corresponding image descriptors. Download the combine images module vicfx.
Import library for MSVC: vicfx.lib
Return value
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Images are not all 8- or 24-bit |
| BAD_DIB | One of the images is a compressed DIB |
blur
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function blur Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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.
-
Result = average of 3 x 3 local region
The image areas are defined by the corresponding image descriptors.
Return value
| NO_ERROR | Function successful |
| BAD_RANGE | Range error (see Appendix A) or Image area is less than 3 x 3 pixels |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Images are not both 8- or 24-bit |
| BAD_DIB | Source or result is a compressed DIB |
blurthresh
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function blurthresh Lib "VIC32.DLL" (ByVal threshold As Long, srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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.
if (Source - average of 3 x 3 region) > threshold
Result = Source
else
Result = average of 3 x 3 local region
The source and result image areas are defined by the corresponding image descriptors.
Return value
| NO_ERROR | Function successful |
| BAD_RANGE | Range error (see Appendix A) or Image area is less than 3 x 3 pixels |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Images are not both 8- or 24-bit |
| BAD_DIB | Source or result is a compressed DIB |
| BAD_FAC | Threshold is outside the range 0 to 255 |
See also
blur
bmpinfo
Function Prototypes
| Visual Basic | Declare Function bmpinfo Lib "VIC32.DLL" (ByVal filename As String, ByRef bminfo As BITMAPINFOHEADER) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_OPN | Filename not found |
| BAD_BMP | File is not a readable BMP format |
See also
loadbmp, savebmp
bmpinfofrombuffer
Function Prototypes
| Visual Basic | Declare Function bmpinfofrombuffer Lib "VIC32.DLL" (ByVal buff As Long, ByRef bminfo As BITMAPINFOHEADER) As Long |
| VB.NET | Declare 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); |
| Java | int 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
brightenmidrange
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function brightenmidrange Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Images are not both 8- or 24-bit |
| BAD_DIB | Source or result is a compressed DIB |
calcavglevel
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function calcavglevel Lib "VIC32.DLL" (srcimg As imgdes, redavg As Long, grnavg As Long, bluavg As Long) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Image is not 8- or 24-bit |
| BAD_DIB | Image is a compressed DIB |
calcavglevelfloat
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function calcavglevelfloat Lib "VICSTATS.DLL" (srcimg As imgdes, redavg As Double, grnavg As Double, bluavg As Double) As Long |
| VB.NET | Declare 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Image is not 8- or 24-bit |
| BAD_DIB | Image is a compressed DIB |
calchisto
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function calchisto Lib "VIC32.DLL" (image As imgdes, redtable As Long, grntable As Long, blutable As Long) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Image is not 8- or 24-bit |
| BAD_DIB | Source or result is a compressed DIB |
See also
calchistorgb
calchistorgb
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function calchistorgb Lib "VIC32.DLL" (image As imgdes, redtable As Long, grntable As Long, blutable As Long, ByVal histoMode As Long) As Long |
| VB.NET | Declare 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); |
| Java | int 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:
| Value | Defined Constant |
| 0 | PALETTEIMAGEASGRAY |
| 1 | PALETTEIMAGEASRGB |
Return value
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Image is not 8- or 24-bit |
| BAD_DIB | Source or result is a compressed DIB |
See also
calchisto
calcminmax
| 8 | 16 | 24 | 32 |
Function Prototypes
| Visual Basic | Declare Function calcminmax Lib "vic32.dll" (srcimg As imgdes, redMinmax As MINMAX, grnMinmax As MINMAX, bluMinmax As MINMAX) As Long |
| VB.NET | Declare 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); |
| Java | int 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:
| min | Minimum 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Image is not 8-, 16-, 24-, or 32-bit |
| BAD_DIB | Image is a compressed DIB |
changebright
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function changebright Lib "VIC32.DLL" (ByVal amount As Long, srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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 = Source + amount
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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Images are not both 8- or 24-bit |
| BAD_DIB | Source or result is a compressed DIB |
| BAD_FAC | Amount to add is outside the range -255 to 255 |
clienttoimage
| 1 | 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function clienttoimage Lib "VIC32.DLL" (ByVal hWnd As Long, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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
cmykimagetorgbimage
| 32 |
Function Prototypes
| Visual Basic | Declare Function cmykimagetorgbimage Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Source is not 32-bit or result is not 24-bit |
| BAD_DIB | Source or result is a compressed DIB |
colordither
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function colordither Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes, ByVal palmode As Long) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error (see Appendix A) or result does not have space for color palette (resimg.palette = 0) |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Source is not 8- or 24-bit or result is not 8-bit |
| BAD_DIB | Source or result is a compressed DIB |
See also
convertrgbtopal, colorscatter
colorscatter
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function colorscatter Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes, ByVal palmode As Long) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error (see Appendix A) or result does not have space for a color palette (resimg.palette = 0) |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Source is not 8- or 24-bit or result is not 8-bit |
| BAD_DIB | Source or result is a compressed DIB |
See also
convertrgbtopal, colordither
colortogray
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function colortogray Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error (see Appendix A) or result does not have space for a color palette (resimg->palette is 0) |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Source is not 8- or 24-bit or result is not 8-bit |
| BAD_DIB | Source or result is a compressed DIB |
convert1bitto8bit
| 1 |
Function Prototypes
| Visual Basic | Declare Function convert1bitto8bit Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Source is not 1-bit or result is not 8-bit |
| BAD_DIB | Source or result is a compressed DIB |
See also
convert8bitto1bit
convert1bitto8bitsmooth
| 1 |
Function Prototypes
| Visual Basic | Declare Function convert1bitto8bitsmooth Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Source is not 1-bit or result is not 8-bit |
| BAD_DIB | Source or result is a compressed DIB |
See also
convert1bitto8bit
convert8bitto1bit
| 8 |
Function Prototypes
| Visual Basic | Declare Function convert8bitto1bit Lib "VIC32.DLL" (ByVal conmode As Long, srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Source is not 8-bit or result is not 1-bit |
| BAD_DIB | Source or result is a compressed DIB |
convert8bitto1bitex
| 8 | 24 |
Function Prototypes
| Visual Basic | Declare Function convert8bitto1bitex Lib "VIC32.DLL" (ByVal conmode As Long, srcimg As imgdes, resimg As imgdes, ByRef dithermatrix_firstelem As byte) As Long |
| VB.NET | Declare 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); |
| Java | int vic.vic32jni.convert8bitto1bitex(int conmode, imgdes srcimg, imgdes resimg, byte [] dithermatrix); |
Function Arguments
| conmode | Conversion mode (0-3) |
| srcimg | Source image |
| resimg | Result image |
| dithermatrix | A 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
| 243 | 67 | 131 | 195 | 251 | 75 | 139 | 203 |
| 163 | 3 | 35 | 99 | 171 | 11 | 43 | 107 |
| 115 | 51 | 19 | 147 | 123 | 59 | 27 | 155 |
| 227 | 179 | 83 | 211 | 236 | 187 | 91 | 219 |
| 240 | 79 | 143 | 207 | 231 | 71 | 135 | 199 |
| 175 | 15 | 47 | 111 | 167 | 7 | 39 | 103 |
| 128 | 63 | 31 | 159 | 119 | 55 | 23 | 151 |
| 255 | 191 | 95 | 221 | 247 | 183 | 87 | 215 |
Return value
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Source is not 8-bit or result is not 1-bit |
| BAD_DIB | Source or result is a compressed DIB |
convertgray8to16
| 8 |
Function Prototypes
| Visual Basic | Declare Function convertgray8to16 Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient memory |
| BAD_BPP | Source is not 8-bit or result is not 16-bit |
| BAD_DIB | Source or result is a compressed DIB |
convertgray16to8
| 16 |
Function Prototypes
| Visual Basic | Declare Function convertgray16to8 Lib "VIC32.DLL" (ByVal min As Long, ByVal max As Long, srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient memory |
| BAD_BPP | Source is not 16-bit or result is not 8-bit |
| BAD_DIB | Source or result is a compressed DIB |
convertgray16to8ex
| 16 |
Function Prototypes
| Visual Basic | Declare Function convertgray16to8ex Lib "VIC32.DLL" (ByVal min As Long, ByVal max As Long, srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient memory |
| BAD_BPP | Source is not 16-bit or result is not 8-bit |
| BAD_DIB | Source or result is a compressed DIB |
convertgray32to8
| 32 |
Function Prototypes
| Visual Basic | Declare Function convertgray32to8 Lib "VIC32.DLL" (ByVal min As Long, ByVal max As Long, srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient memory |
| BAD_BPP | Source is not 32-bit or result is not 8-bit |
| BAD_DIB | Source or result is a compressed DIB |
convertgray32to16
| 32 |
Function Prototypes
| Visual Basic | Declare Function convertgray32to16 Lib "VIC32.DLL" (ByVal min As Long, ByVal max As Long, srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient memory |
| BAD_BPP | Source is not 32-bit or result is not 16-bit |
| BAD_DIB | Source or result is a compressed DIB |
convertpaltorgb
| 8 |
Function Prototypes
| Visual Basic | Declare Function convertpaltorgb Lib "VIC32.DLL" (srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Source is not 8- or result is not 24-bit |
| BAD_DIB | Source or result is a compressed DIB |
convertrgbtopal
| 24 |
Function Prototypes
| Visual Basic | Declare Function convertrgbtopal Lib "VIC32.DLL" (ByVal palcolors As Long, srcimg As imgdes, resimg As imgdes) As Long |
| VB.NET | Declare 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); |
| Java | int 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:
- Analyze the red, green, and blue contributions to each pixel and determine the population of each color in the image.
- Select up to 256 unique colors that best represent the entire image and assign these to the result palette.
- Compute the result image by assigning each pixel from the RGB image to one of the colors in the result palette.
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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Source is not 24- or result is not 8-bit |
| BAD_DIB | Source or result is a compressed DIB |
| BAD_FAC | Palcolors is outside the range 2 to 256 |
See also
convertrgbtopalex, colordither, colorscatter
convertrgbtopalex
| 24 |
Function Prototypes
| Visual Basic | Declare Function convertrgbtopalex Lib "VIC32.DLL" (ByVal palcolors As Long, srcimg As imgdes, resimg As imgdes, ByVal colredmode As Long) As Long |
| VB.NET | Declare 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); |
| Java | int 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:
- Analyze the red, green, and blue contributions to each pixel and determine the population of each color in the image.
- Select up to 256 unique colors that best represent the entire image and assign these to the result palette.
- Compute the result image by assigning each pixel from the RGB image to one of the colors in the result palette.
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 |
-
1Method used by convertrgbtopal function
2TSD = Through space distance
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
| NO_ERROR | Function successful |
| BAD_RANGE | Range error, see Appendix A |
| BAD_IBUF | Invalid image buffer address |
| BAD_MEM | Insufficient local memory |
| BAD_BPP | Source is not 24- or result is not 8-bit |
| BAD_DIB | Source or result is a compressed DIB |
| BAD_FAC | Palcolors is outside the range 2 to 256, or colredmode is not 0 to 3 |
See also
colordither, colorscatter
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.NET | Declare 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 correlati