📄 cximage_reference.htm
字号:
<html>
<head>
<title>CxImage reference</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
<h2>CxImage Class Members & Operations</h2>
<ul>
<li> <a href="#Construction">Constructors</a>
<li> <a href="#Initialization">Initialization</a>
<li> <a href="#File">File</a>
<li> <a href="#Image">Generic</a>
<li> <a href="#DSP">DSP</a>
<li> <a href="#Painting">Painting</a>
<li> <a href="#Multiple">Multiple Images</a>
<li> <a href="#Transparency">Transparency</a>
<li> <a href="#Palette">Palette</a>
<li> <a href="#Pixels">Pixels</a>
<li> <a href="#Region">Region Selection</a>
<li> <a href="#Alpha">Alpha Channel</a>
<li><a href="#layers">Layers</a>
<li> <a href="#Attributes">Attributes</a>
<li> <a href="#Miscellaneous">Miscellaneous</a><br>
</li>
</ul>
<h3><b>Supported file formats</b></h3>
<p>At the begining of the main header file <code>ximage.h</code> you'll find the
definitions to enable or disable a specific format:<br>
<code>// CxImage supported formats<br>
#define CXIMAGE_SUPPORT_BMP 1<br>
#define CXIMAGE_SUPPORT_GIF 1<br>
#define CXIMAGE_SUPPORT_JPG 1<br>
#define CXIMAGE_SUPPORT_PNG 1<br>
#define CXIMAGE_SUPPORT_MNG 0<br>
#define CXIMAGE_SUPPORT_ICO 1<br>
#define CXIMAGE_SUPPORT_TIF 1<br>
#define CXIMAGE_SUPPORT_TGA 1<br>
#define CXIMAGE_SUPPORT_PCX 1<br>
#define CXIMAGE_SUPPORT_WBMP 1<br>
#define CXIMAGE_SUPPORT_WMF 1<br>
#define CXIMAGE_SUPPORT_J2K 0<br>
#define CXIMAGE_SUPPORT_JBG 0<br>
#define CXIMAGE_SUPPORT_JP2 1<br>
#define CXIMAGE_SUPPORT_JPC 1<br>
#define CXIMAGE_SUPPORT_PGX 1<br>
#define CXIMAGE_SUPPORT_PNM 1<br>
#define CXIMAGE_SUPPORT_RAS 1<br></code>
Remember to rebuild the library if you change these statements.</p>
<h3><b>Construction<a name="Construction"></a></b></h3>
<table width="100%" border="1" cellspacing="0">
<tbody>
<tr valign="top">
<td width="47%"><code>CxImage(DWORD imagetype=0)</code></td>
<td width="50%">Creates an empty image. <code>imagetype</code> (optional)
sets the image format.</td>
</tr>
<tr valign="top">
<td width="47%"><code>CxImage(DWORD dwWidth, DWORD dwHeight, DWORD wBpp, DWORD
imagetype=0)</code></td>
<td width="50%">
Creates an image with the specified width, height, bit per pixel and (optional)
image type arguments.</td>
</tr>
<tr valign="top">
<td width="47%"><code>CxImage(const CxImage &isrc, bool copypixels=true, bool
copyselection=true, bool copyalpha=true)</code></td>
<td width="50%">Creates an image with the same characteristics of the source image.</td>
</tr>
<tr valign="top">
<td width="47%">
<p><code>CxImage(const TCHAR * filename, DWORD imagetype)<br>
<br>
CxImage(FILE * stream, DWORD imagetype)<br>
<br>
CxImage(CxFile * stream, DWORD imagetype)<br>
<br>
CxImage(BYTE * buffer, DWORD size, DWORD imagetype)</code></p>
</td>
<td width="50%">Creates an image from file or memory. <code>imagetype</code> can be
one of these formats:<br>
<code>CXIMAGE_FORMAT_JPG, CXIMAGE_FORMAT_TIF, CXIMAGE_FORMAT_MNG, CXIMAGE_FORMAT_BMP,
CXIMAGE_FORMAT_ICO, CXIMAGE_FORMAT_GIF, CXIMAGE_FORMAT_PNG, CXIMAGE_FORMAT_PCX,
CXIMAGE_FORMAT_TGA, CXIMAGE_FORMAT_WMF, CXIMAGE_FORMAT_JBG, CXIMAGE_FORMAT_J2K,<br>
CXIMAGE_FORMAT_JP2, CXIMAGE_FORMAT_JPC, CXIMAGE_FORMAT_PGX,<br>
CXIMAGE_FORMAT_PNM, CXIMAGE_FORMAT_RAS, CXIMAGE_FORMAT_WBMP</code><br>
For automatic image type detection use <code>CXIMAGE_FORMAT_UNKNOWN</code></td>
</tr>
</tbody>
</table>
<h3><b>Initialization</b><a name="Initialization"></a>
</h3>
<table width="100%" border="1" cellspacing="0">
<tbody>
<tr valign="top">
<td width="47%"><code>void* Create(DWORD dwWidth, DWORD dwHeight, DWORD wBpp,
DWORD imagetype=0)</code></td>
<td width="50%">
Initializes or rebuilds the image. Returns the pointer to the internal pDib
object.</td>
</tr>
<tr valign="top">
<td width="47%"><code>void Clear(BYTE bval=0)</code></td>
<td width="50%">Sets the image bits to the specified value.</td>
</tr>
<tr valign="top">
<td width="47%"><code> bool Destroy()</code></td>
<td width="50%">Releases the image buffers.</td>
</tr>
<tr valign="top">
<td width="47%"><code>void Copy(const CxImage &src, bool copypixels = true, bool
copyselection = true, bool copyalpha = true)</code></td>
<td width="50%">Copies the image from an exsisting one.</td>
</tr>
<tr valign="top">
<td width="47%"><code>HANDLE CopyToHandle()</code></td>
<td width="50%">Copies the image to a global memory handle (clipboard operations)</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool CreateFromHBITMAP(HBITMAP hbmp, HPALETTE hpal=0)<br>
<br>
bool CreateFromHICON(HICON hico)</code></td>
<td width="50%">Creates an image from a bitmap or icon object. (resource)</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool CreateFromHANDLE(HANDLE hMem)</code></td>
<td width="50%">Creates an image from a global bitmap handle. (clipboard
operations)</td>
</tr>
<tr valign="top">
<td width="47%"><code> bool CreateFromArray(BYTE* pArray,DWORD dwWidth,DWORD
dwHeight,DWORD dwBitsperpixel, DWORD dwBytesperline, bool bFlipImage);<br>
<br>
bool CreateFromMatrix(BYTE** ppMatrix,DWORD dwWidth,DWORD dwHeight,DWORD
dwBitsperpixel, DWORD dwBytesperline, bool bFlipImage);<br>
</code></td>
<td width="50%">
<p>Creates an image from a generic buffer.<br>
<code>dwBitsperpixel</code> can be 1,4,8,24,32</p>
</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool Transfer(CxImage &from)</code></td>
<td width="50%">Transfers the image from an existing source image. The source
become empty.</td>
</tr>
</tbody>
</table>
<h3>File<a name="File"></a> operations</h3>
<table width="100%" border="1" cellspacing="0">
<tbody>
<tr valign="top">
<td width="47%" height="27"><code>bool LoadResource(HRSRC hRes, DWORD imagetype,
HMODULE hModule=NULL)</code></td>
<td width="50%" height="27">Loads an image from the application resources.<br>
<code>hRes</code> is the resource handle returned by <code>FindResource()</code>.</td>
</tr>
<tr valign="top">
<td width="47%" height="97"><code>bool Save(const TCHAR * filename,DWORD imagetype=0)</code><br>
<br>
<code>bool Encode(FILE * hFile, DWORD imagetype)</code><br>
<br>
<code>bool Encode(CxFile * hFile, DWORD imagetype)</code> <br>
<br>
<code>bool Encode(BYTE * &buffer, long &size, DWORD imagetype)</code>
<br>
</td>
<td width="50%" height="97">Saves to disk or memory the image in a specific
format.<br>
(Note: <code>buffer</code> must be NULL, the function allocates and fill the
memory, the application must free the buffer)</td>
</tr>
<tr valign="top">
<td width="47%" height="52"><code>bool Load(const TCHAR * filename,DWORD imagetype=0)</code><br>
<br>
<code>bool Decode(FILE * hFile, DWORD imagetype)</code><br>
<br>
<code>bool Decode(CxFile * hFile, DWORD imagetype)</code> <br>
<br>
<code>bool Decode(BYTE * buffer, DWORD size, DWORD imagetype)</code>
<br>
</td>
<td width="50%" height="52">Reads from disk or memory the image in a specific
format.</td>
</tr>
<tr valign="top">
<td width="47%" height="52"> <code>bool Encode(CxFile * hFile, CxImage **
pImages, int pagecount, DWORD imagetype);<br>
<br>
bool Encode(FILE *hFile, CxImage ** pImages, int pagecount, DWORD imagetype);</code>
</td>
<td width="50%" height="52">Saves to disk or memory <code>pagecount</code> images,
referenced by an array of <code>CxImage</code> pointers. <code>imagetype</code>
can be <code>CXIMAGE_FORMAT_TIF</code> or <code>CXIMAGE_FORMAT_GIF</code></td>
</tr>
</tbody>
</table>
<h3>Image<a name="Image"></a> operations</h3>
<table width="100%" border="1" cellspacing="0">
<TBODY>
<tr valign="top">
<td width="47%"><code>bool IsValid()</code></td>
<td width="50%">Checks if the image is correctly initializated.</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool IsEnabled()</code></td>
<td width="50%">True if the image is enabled for painting.</td>
</tr>
<tr valign="top">
<td width="47%"><code>void Enable(bool enable=true)</code></td>
<td width="50%">Enables/disables the image.</td>
</tr>
<tbody>
<tr valign="top">
<td width="47%"><code>bool Flip()</code></td>
<td width="50%">Flips upside down the image.</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool Mirror()</code></td>
<td width="50%">Mirrors the image.</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool Rotate(float angle, CxImage* iDst = NULL)<br>
<br>
bool RotateLeft(CxImage* iDst = NULL)<br>
<br>
bool RotateRight(CxImage* iDst = NULL)<br>
<br>
bool Rotate180(CxImage* iDst = NULL) </code> </td>
<td width="50%">Rotates the image. <code>angle</code> can be positive for
clockwise rotation or negative for counter-clockwise rotation. If <code>iDst</code>
is NULL, the resulting image replaces the original.</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool Negative()</code></td>
<td width="50%">Inverts the image colors.</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool GrayScale()</code></td>
<td width="50%"> Converts the image colors to 8 bit gray scale.</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool Resample(long newx, long newy, int mode = 1, CxImage*
iDst = NULL)</code><br>
</td>
<td width="50%">Resizes the image. <code>mode</code> can be 0 for slow (bilinear)
method , 1 for fast (nearest pixel) method, or 2 for accurate (bicubic spline
interpolation) method. The function is faster with 24 and 1 bpp images,
slow for 4 bpp images and slowest for 8 bpp images.</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool DecreaseBpp(DWORD nbit, bool errordiffusion, RGBQUAD*
ppal = 0)</code></td>
<td width="50%">Reduces the number of bits per pixel to <code>nbit</code>
(1, 4 or 8).<br>
<code>ppal</code> points to a valid palette for the final image; if not
supplied the function will use a standard palette. <code>ppal</code> is
not necessary for reduction to 1 bpp.</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool IncreaseBpp(DWORD nbit)</code></td>
<td width="50%">Increases the number of bits per pixel of the image.</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool Dither(long method = 0)</code></td>
<td width="50%"> Converts the image to B&W using the Floyd-Steinberg (<code>method</code>
= 0) or Ordered-Dithering (<code>method</code> = 1) algorithms. </td>
</tr>
<tr valign="top">
<td width="47%"><code>bool Crop(long left, long top, long right, long bottom,
CxImage* iDst = NULL)<br>
<br>
bool Crop(const RECT& rect, CxImage* iDst = NULL) <br>
<br>
bool CropRotatedRectangle( long topx, long topy, long width, long height,
float angle, CxImage* iDst = NULL); </code> </td>
<td width="50%"> Extracts the specified rectangle from the image. If <code>iDst</code>
is NULL, the resulting image replaces the original.</td>
</tr>
<tr valign="top">
<td width="47%" height="112"><code>bool CircleTransform(int type,long rmax=0,float
Koeff=1.0f);</code></td>
<td width="50%" height="112">Perform circle_based transformations. <code>type</code>
is for different transformations :<br>
- 0 for normal (proturberant) FishEye<br>
- 1 for reverse (concave) FishEye<br>
- 2 for Swirle <br>
- 3 for Cilinder mirror<br>
- 4 for bathroom</td>
</tr>
<tr valign="top">
<td width="47%"><code> bool Expand(long left, long top, long right, long bottom,
RGBQUAD canvascolor, CxImage* iDst = 0);<br>
<br>
bool Expand(long newx, long newy, RGBQUAD canvascolor, CxImage* iDst = 0);<br>
</code></td>
<td width="50%">Expands the borders.</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool Thumbnail(long newx, long newy, RGBQUAD canvascolor,
CxImage* iDst = 0);</code></td>
<td width="50%">Resamples the image with the correct aspect ratio, and fills
the borders.</td>
</tr>
</tbody>
</table>
<h3>DSP<a name="DSP"></a> operations</h3>
<table width="100%" border="1" cellspacing="0">
<tr valign="top">
<td width="47%"><code>bool Threshold(BYTE level)</code></td>
<td width="50%">Converts the image to B&W. <code>level</code> is the lightness
threshold. The <code>Mean()</code> function can be used for calculating
the optimal threshold.</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool SplitRGB(CxImage* r,CxImage* g,CxImage* b)<br>
<br>
bool SplitYUV(CxImage* y,CxImage* u,CxImage* v)<br>
<br>
bool SplitHSL(CxImage* h,CxImage* s,CxImage* l)<br>
<br>
bool SplitYIQ(CxImage* y,CxImage* i,CxImage* q)<br>
<br>
bool SplitXYZ(CxImage* x,CxImage* y,CxImage* z)<br>
<br>
bool SplitCMYK(CxImage* c,CxImage* m,CxImage* y,CxImage* k) </code> </td>
<td width="50%">Extract various channels from the image. Each channel is an
8 bit grayscale image. </td>
</tr>
<tr valign="top">
<td width="47%"><code>bool Colorize(BYTE hue, BYTE sat)</code></td>
<td width="50%"> Replaces the original hue and saturation values with <code>hue</code>
and <code>sat</code>.</td>
</tr>
<tr valign="top">
<td width="47%"><code>bool Light(long brightness, long contrast=0)</code></td>
<td width="50%">Changes the brightness and the contrast of the image. <code>level</code>
can be from -255 to 255, if <code>level</code> is negative, the image becomes
dark. <code>contrast</code> can be from -100 to 100, the neutral value
is 0.</td>
</tr>
<tr valign="top">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -