diff options
-rw-r--r-- | html/en/history.html | 23 | ||||
-rw-r--r-- | include/im_capture.h | 34 | ||||
-rw-r--r-- | include/im_image.h | 27 | ||||
-rw-r--r-- | include/im_process_ana.h | 8 | ||||
-rw-r--r-- | include/im_process_pon.h | 10 | ||||
-rw-r--r-- | mak.vc9/im.vcproj | 4 | ||||
-rw-r--r-- | mak.vc9/im_avi.vcproj | 4 | ||||
-rw-r--r-- | mak.vc9/im_capture.vcproj | 4 | ||||
-rw-r--r-- | mak.vc9/im_ecw.vcproj | 4 | ||||
-rw-r--r-- | mak.vc9/im_fftw.vcproj | 4 | ||||
-rw-r--r-- | mak.vc9/im_jp2.vcproj | 4 | ||||
-rw-r--r-- | mak.vc9/im_process.vcproj | 4 | ||||
-rw-r--r-- | mak.vc9/im_wmv.vcproj | 4 | ||||
-rw-r--r-- | mak.vc9/imlua3.vcproj | 4 | ||||
-rw-r--r-- | mak.vc9/imlua5.vcproj | 4 | ||||
-rw-r--r-- | mak.vc9/imlua_capture5.vcproj | 4 | ||||
-rw-r--r-- | mak.vc9/imlua_fftw5.vcproj | 4 | ||||
-rw-r--r-- | mak.vc9/imlua_process5.vcproj | 4 | ||||
-rw-r--r-- | src/im.def | 2 | ||||
-rw-r--r-- | src/im_image.cpp | 210 | ||||
-rw-r--r-- | src/lua5/imlua_capture.c | 58 | ||||
-rw-r--r-- | src/lua5/imlua_image.c | 35 | ||||
-rw-r--r-- | src/lua5/imlua_process.c | 8 |
23 files changed, 375 insertions, 92 deletions
diff --git a/html/en/history.html b/html/en/history.html index 108841b..d4c4b23 100644 --- a/html/en/history.html +++ b/html/en/history.html @@ -12,22 +12,35 @@ <h1>History of Changes</h1> <h3 dir="ltr"> - CVS (04/Aug/2009)</h3> + CVS (11/Aug/2009)</h3> <ul> - <li><span style="color: #008000">Changed:</span> libPNG updated to version + <li><span style="color: #0000FF">New:</span> function <strong> + imImageGetOpenGLData</strong>.</li> + <li><span style="color: #008000">Changed:</span> libPNG updated to version 1.2.37. Removed changes to the library that made it incompatible with other libPNG distributions.</li> + <li><span style="color: #008000">Changed: <span + style="color: #000000"> <strong>imImageCreateBased</strong> now also + consider the alpha plane.</span></span></li> <li><span style="color: #008000"><span style="color: #ff0000">Fixed:</span><span style="color: #000000"> new image size computation of <strong>im.ProcessCropNew</strong> in Lua.</span></span> </li> <li><span style="color: #008000"><span style="color: #ff0000">Fixed:</span><span style="color: #000000"> loading of RAW data.</span></span></li> <li><span style="color: #008000"><span style="color: #ff0000">Fixed:</span><span + style="color: #000000"> <strong>imImageClear</strong> to initialize + data just like <strong>imImageCreate</strong> does. </span></span></li> + <li><span style="color: #008000"><span style="color: #ff0000">Fixed:</span><span + style="color: #000000"> <strong>imImageReshape</strong> when the + image has an alpha plane. Image is not cleared anymore. </span></span></li> + <li><span style="color: #008000"><span style="color: #ff0000">Fixed:</span><span style="color: #000000"> boolean parameters in <strong> - file:ReadImageData, im.ProcessSplitComplex, + file:ReadImageData, im.ConvertDataType, im.ConvertToBitmap, im.ProcessSplitComplex, im.ProcessQuantizeRGBUniform, im.ProcessBitPlane, im.ProcessRotateRef, - im.ProcessRotate90, im.ProcessBinMorphConvolve, im.ConvertDataType</strong> - and <strong>im.ConvertToBitmap</strong> in Lua.</span></span></li> + im.ProcessRotate90, im.ProcessBinMorphConvolve, im.ProcessMergeComplex, + im.CalcHistogram, im.CalcGrayHistogram </strong>and <strong> + im.AnalyzeFindRegions</strong> in Lua. Changed <strong>im.Capture*</strong> + functions to use boolean values in Lua.</span></span></li> </ul> <h3 dir="ltr"> Version 3.4.2 (26/Jun/2009)</h3> diff --git a/include/im_capture.h b/include/im_capture.h index 7c130a3..bc5f732 100644 --- a/include/im_capture.h +++ b/include/im_capture.h @@ -47,19 +47,19 @@ const char* IM_DECL imVideoCaptureDeviceDesc(int device); * * \verbatim im.VideoCaptureDeviceExDesc(device: number) -> desc: string [in Lua 5] \endverbatim * \ingroup capture */ -const char* imVideoCaptureDeviceExDesc(int device); +const char* IM_DECL imVideoCaptureDeviceExDesc(int device); /** Returns the device path configuration. This is a unique string. * * \verbatim im.VideoCaptureDevicePath(device: number) -> desc: string [in Lua 5] \endverbatim * \ingroup capture */ -const char* imVideoCaptureDevicePath(int device); +const char* IM_DECL imVideoCaptureDevicePath(int device); /** Returns the vendor information. May return NULL. * * \verbatim im.VideoCaptureDeviceVendorInfo(device: number) -> desc: string [in Lua 5] \endverbatim * \ingroup capture */ -const char* imVideoCaptureDeviceVendorInfo(int device); +const char* IM_DECL imVideoCaptureDeviceVendorInfo(int device); /** Reload the device list. The devices can be dynamically removed or added to the system. * Returns the number of available devices. @@ -117,17 +117,17 @@ int IM_DECL imVideoCaptureDialogCount(imVideoCapture* vc); * dialog can be from 0 to \ref imVideoCaptureDialogCount. \n * Returns zero if failed. * - * \verbatim vc:ShowDialog(dialog: number, parent: userdata) -> error: number [in Lua 5] \endverbatim + * \verbatim vc:ShowDialog(dialog: number, parent: userdata) -> error: boolean [in Lua 5] \endverbatim * \ingroup capture */ int IM_DECL imVideoCaptureShowDialog(imVideoCapture* vc, int dialog, void* parent); /** Allows to control the input and output of devices that have multiple input and outputs. - * cross controls in which stage the input/output will be set. Usually use 1, but some capture boards + * The cross index controls in which stage the input/output will be set. Usually use 1, but some capture boards * has a second stage. In Direct X it controls the crossbars. * - * \verbatim vc:SetInOut(input, output, cross: number) -> error: number [in Lua 5] \endverbatim + * \verbatim vc:SetInOut(input, output, cross: number) -> error: boolean [in Lua 5] \endverbatim * \ingroup capture */ -int imVideoCaptureSetInOut(imVideoCapture* vc, int input, int output, int cross); +int IM_DECL imVideoCaptureSetInOut(imVideoCapture* vc, int input, int output, int cross); /** Returns the description of a configuration dialog. * dialog can be from 0 to \ref imVideoCaptureDialogCount. \n @@ -139,7 +139,7 @@ const char* IM_DECL imVideoCaptureDialogDesc(imVideoCapture* vc, int dialog); /** Returns the number of available video formats. \n * Returns zero if failed. * - * \verbatim vc:FormatCount() -> error: number [in Lua 5] \endverbatim + * \verbatim vc:FormatCount() -> count: number [in Lua 5] \endverbatim * \ingroup capture */ int IM_DECL imVideoCaptureFormatCount(imVideoCapture* vc); @@ -150,7 +150,7 @@ int IM_DECL imVideoCaptureFormatCount(imVideoCapture* vc); * Other sizes can be available using \ref imVideoCaptureSetImageSize. \n * Returns zero if failed. * - * \verbatim vc:GetFormat(format: number) -> error: number, width: number, height: number, desc: string [in Lua 5] \endverbatim + * \verbatim vc:GetFormat(format: number) -> error: boolean, width: number, height: number, desc: string [in Lua 5] \endverbatim * \ingroup capture */ int IM_DECL imVideoCaptureGetFormat(imVideoCapture* vc, int format, int *width, int *height, char* desc); @@ -162,7 +162,7 @@ int IM_DECL imVideoCaptureGetFormat(imVideoCapture* vc, int format, int *width, * This will not affect color_mode of the capture image. \n * Returns zero if failed. * - * \verbatim vc:SetFormat(format: number) -> error: number [in Lua 5] \endverbatim + * \verbatim vc:SetFormat([format: number]) -> error: boolean | format: number [in Lua 5] \endverbatim * \ingroup capture */ int IM_DECL imVideoCaptureSetFormat(imVideoCapture* vc, int format); @@ -178,7 +178,7 @@ void IM_DECL imVideoCaptureGetImageSize(imVideoCapture* vc, int *width, int *hei * Valid sizes can be obtained with \ref imVideoCaptureGetFormat. \n * Returns zero if failed. * - * \verbatim vc:SetImageSize(width: number, height: number) -> error: number [in Lua 5] \endverbatim + * \verbatim vc:SetImageSize(width: number, height: number) -> error: boolean [in Lua 5] \endverbatim * \ingroup capture */ int IM_DECL imVideoCaptureSetImageSize(imVideoCapture* vc, int width, int height); @@ -188,7 +188,7 @@ int IM_DECL imVideoCaptureSetImageSize(imVideoCapture* vc, int width, int height * It can not have an alpha channel and orientation is always bottom up. \n * Returns zero if failed or timeout expired, the buffer is not changed. * - * \verbatim vc:Frame(image: imImage, timeout: number) -> error: number [in Lua 5] \endverbatim + * \verbatim vc:Frame(image: imImage, timeout: number) -> error: boolean [in Lua 5] \endverbatim * \ingroup capture */ int IM_DECL imVideoCaptureFrame(imVideoCapture* vc, unsigned char* data, int color_mode, int timeout); @@ -197,7 +197,7 @@ int IM_DECL imVideoCaptureFrame(imVideoCapture* vc, unsigned char* data, int col * Data format is the same as imVideoCaptureFrame. \n * Returns zero if failed. * - * \verbatim vc:OneFrame(image: imImage) -> error: number [in Lua 5] \endverbatim + * \verbatim vc:OneFrame(image: imImage) -> error: boolean [in Lua 5] \endverbatim * \ingroup capture */ int IM_DECL imVideoCaptureOneFrame(imVideoCapture* vc, unsigned char* data, int color_mode); @@ -205,7 +205,7 @@ int IM_DECL imVideoCaptureOneFrame(imVideoCapture* vc, unsigned char* data, int * Use -1 to return the current state. \n * Returns zero if failed. * - * \verbatim vc:Live(live: number) -> error: number [in Lua 5] \endverbatim + * \verbatim vc:Live([live: number]) -> error: boolean | live: number [in Lua 5] \endverbatim * \ingroup capture */ int IM_DECL imVideoCaptureLive(imVideoCapture* vc, int live); @@ -214,21 +214,21 @@ int IM_DECL imVideoCaptureLive(imVideoCapture* vc, int live); * Not all attributes support automatic modes. \n * Returns zero if failed. * - * \verbatim vc:ResetAttribute(attrib: string, fauto: number) -> error: number [in Lua 5] \endverbatim + * \verbatim vc:ResetAttribute(attrib: string, fauto: boolean) -> error: boolean [in Lua 5] \endverbatim * \ingroup capture */ int IM_DECL imVideoCaptureResetAttribute(imVideoCapture* vc, const char* attrib, int fauto); /** Returns a camera or video attribute in percentage of the valid range value. \n * Returns zero if failed or attribute not supported. * - * \verbatim vc:GetAttribute(attrib: string) -> error: number, percent: number [in Lua 5] \endverbatim + * \verbatim vc:GetAttribute(attrib: string) -> error: boolean, percent: number [in Lua 5] \endverbatim * \ingroup capture */ int IM_DECL imVideoCaptureGetAttribute(imVideoCapture* vc, const char* attrib, float *percent); /** Changes a camera or video attribute in percentage of the valid range value. \n * Returns zero if failed or attribute not supported. * - * \verbatim vc:SetAttribute(attrib: string, percent: number) -> error: number [in Lua 5] \endverbatim + * \verbatim vc:SetAttribute(attrib: string, percent: number) -> error: boolean [in Lua 5] \endverbatim * \ingroup capture */ int IM_DECL imVideoCaptureSetAttribute(imVideoCapture* vc, const char* attrib, float percent); diff --git a/include/im_image.h b/include/im_image.h index fca3212..f0cc4f3 100644 --- a/include/im_image.h +++ b/include/im_image.h @@ -68,7 +68,7 @@ typedef struct _imImage /** Creates a new image. - * See also \ref imDataType and \ref imColorSpace. \n + * See also \ref imDataType and \ref imColorSpace. Image data is cleared as \ref imImageClear. \n * In Lua the IM image metatable name is "imImage". * When converted to a string will return "imImage(%p) [width=%d,height=%d,color_space=%s,data_type=%s,depth=%d]" where %p is replaced by the userdata address, * and other values are replaced by the respective attributes. @@ -85,7 +85,7 @@ imImage* imImageInit(int width, int height, int color_space, int data_type, void /** Creates a new image based on an existing one. \n * If the addicional parameters are -1, the given image parameters are used. \n - * The image atributes always are copied. + * The image atributes always are copied. HasAlpha is copied. * See also \ref imDataType and \ref imColorSpace. * * \verbatim im.ImageCreateBased(image: imImage, [width: number], [height: number], [color_space: number], [data_type: number]) -> image: imImage [in Lua 5] \endverbatim @@ -141,6 +141,14 @@ imImage* imImageDuplicate(const imImage* image); * \ingroup imgclass */ imImage* imImageClone(const imImage* image); +/** Returns an OpenGL compatible data buffer. Also returns the correspondant pixel format. \n + * The memory allocated is stored in the attribute "GLDATA" with BYTE type. And it will exists while the image exists. \n + * It can also be cleared setting the attribute to NULL. + * + * \verbatim image:GetOpenGLData() -> gldata: userdata, format: number [in Lua 5] \endverbatim + * \ingroup imgclass */ +void* imImageGetOpenGLData(imImage* image, int *format); + /** Changes an extended attribute. \n * The data will be internally duplicated. \n * If data is NULL the attribute is removed. \n @@ -168,7 +176,8 @@ const void* imImageGetAttribute(const imImage* image, const char* attrib, int *d * \ingroup imgclass */ void imImageGetAttributeList(const imImage* image, char** attrib, int *attrib_count); -/** Sets all image data to zero. +/** Sets all image data to zero. But if color space is YCBCR, LAB or LUV, and data type is BYTE or USHORT, then + * data is initialized with 128 or 32768 accordingly. * * \verbatim image:Clear() [in Lua 5] \endverbatim * \ingroup imgclass */ @@ -230,12 +239,18 @@ int imImageMatch(const imImage* image1, const imImage* image2); * \ingroup imgclass */ void imImageSetBinary(imImage* image); -/** Changes a gray data into a binary data, done in-place. +/** Changes a gray BYTE data (0,255) into a binary data (0,1), done in-place. Color space is not changed. * * \verbatim image:MakeBinary() [in Lua 5] \endverbatim * \ingroup imgclass */ void imImageMakeBinary(imImage *image); +/** Changes a binary data (0,1) into a gray BYTE data (0,255), done in-place. Color space is not changed. + * + * \verbatim image:MakeGray() [in Lua 5] \endverbatim + * \ingroup imgclass */ +void imImageMakeGray(imImage *image); + /** \defgroup imgfile imImage Storage @@ -292,7 +307,7 @@ imImage* imFileLoadBitmap(imFile* ifile, int index, int *error); * or will be a Bitmap image. \n * Attributes from the file will be stored at the image. * See also \ref imErrorCodes. \n - * For now works only for ECW file format. + * For now, it works only for the ECW file format. * * \verbatim ifile:LoadRegion(index, bitmap, xmin, xmax, ymin, ymax, width, height: number) -> image: imImage, error: number [in Lua 5] \endverbatim * Default index is 0. @@ -349,7 +364,7 @@ imImage* imFileImageLoadBitmap(const char* file_name, int index, int *error); * Returns NULL if failed. * Attributes from the file will be stored at the image. * See also \ref imErrorCodes. \n - * For now works only for ECW file format. + * For now, it works only for the ECW file format. * * \verbatim im.FileImageLoadRegion(file_name: string, index, bitmap, xmin, xmax, ymin, ymax, width, height: number, ) -> image: imImage, error: number [in Lua 5] \endverbatim * Default index is 0. diff --git a/include/im_process_ana.h b/include/im_process_ana.h index 2458be3..2853e02 100644 --- a/include/im_process_ana.h +++ b/include/im_process_ana.h @@ -45,7 +45,7 @@ unsigned long imCalcCountColors(const imImage* image); * Histogram is always 256 positions long. \n * When cumulative is different from zero it calculates the cumulative histogram. * - * \verbatim im.CalcHistogram(image: imImage, plane: number, cumulative: number) -> histo: table of numbers [in Lua 5] \endverbatim + * \verbatim im.CalcHistogram(image: imImage, plane: number, cumulative: boolean) -> histo: table of numbers [in Lua 5] \endverbatim * Where plane is the depth plane to calculate the histogram. \n * The returned table is zero indexed. image can be IM_USHORT or IM_BYTE. * \ingroup stats */ @@ -64,7 +64,7 @@ void imCalcUShortHistogram(const unsigned short* data, int count, unsigned long* * Histogram is always 256 positions long. \n * When cumulative is different from zero it calculates the cumulative histogram. * - * \verbatim im.CalcGrayHistogram(image: imImage, cumulative: number) -> histo: table of numbers [in Lua 5] \endverbatim + * \verbatim im.CalcGrayHistogram(image: imImage, cumulative: boolean) -> histo: table of numbers [in Lua 5] \endverbatim * \ingroup stats */ void imCalcGrayHistogram(const imImage* image, unsigned long* histo, int cumulative); @@ -120,8 +120,8 @@ void imCalcHistoImageStatistics(const imImage* image, int* median, int* mode); * Returns the number of regions found. Background is marked as 0. \n * Regions touching the border are considered only if touch_border=1. * - * \verbatim im.AnalyzeFindRegions(src_image: imImage, dst_image: imImage, connect: number, touch_border: number) -> count: number [in Lua 5] \endverbatim - * \verbatim im.AnalyzeFindRegionsNew(image: imImage, connect: number, touch_border: number) -> count: number, new_image: imImage [in Lua 5] \endverbatim + * \verbatim im.AnalyzeFindRegions(src_image: imImage, dst_image: imImage, connect: number, touch_border: boolean) -> count: number [in Lua 5] \endverbatim + * \verbatim im.AnalyzeFindRegionsNew(image: imImage, connect: number, touch_border: boolean) -> count: number, new_image: imImage [in Lua 5] \endverbatim * \ingroup analyze */ int imAnalyzeFindRegions(const imImage* src_image, imImage* dst_image, int connect, int touch_border); diff --git a/include/im_process_pon.h b/include/im_process_pon.h index cfed5ae..bf09a71 100644 --- a/include/im_process_pon.h +++ b/include/im_process_pon.h @@ -122,17 +122,17 @@ void imProcessBlend(const imImage* src_image1, const imImage* src_image2, const * or magnitude and phase parts (polar). \n * Source image must be IM_CFLOAT, destiny images must be IM_FLOAT. * - * \verbatim im.ProcessSplitComplex(src_image: imImage, dst_image1: imImage, dst_image2: imImage, do_polar: boolean) [in Lua 5] \endverbatim - * \verbatim im.ProcessSplitComplexNew(image: imImage, do_polar: boolean) -> dst_image1: imImage, dst_image2: imImage [in Lua 5] \endverbatim + * \verbatim im.ProcessSplitComplex(src_image: imImage, dst_image1: imImage, dst_image2: imImage, polar: boolean) [in Lua 5] \endverbatim + * \verbatim im.ProcessSplitComplexNew(image: imImage, polar: boolean) -> dst_image1: imImage, dst_image2: imImage [in Lua 5] \endverbatim * \ingroup arithm */ -void imProcessSplitComplex(const imImage* src_image, imImage* dst_image1, imImage* dst_image2, int do_polar); +void imProcessSplitComplex(const imImage* src_image, imImage* dst_image1, imImage* dst_image2, int polar); /** Merges two images as the real and imaginary parts of a complex image, \n * or as magnitude and phase parts (polar = 1). \n * Source images must be IM_FLOAT, destiny image must be IM_CFLOAT. * - * \verbatim im.ProcessMergeComplex(src_image1: imImage, src_image2: imImage, dst_image: imImage) [in Lua 5] \endverbatim - * \verbatim im.ProcessMergeComplexNew(image1: imImage, image2: imImage) -> new_image: imImage [in Lua 5] \endverbatim + * \verbatim im.ProcessMergeComplex(src_image1: imImage, src_image2: imImage, dst_image: imImage, polar: boolean) [in Lua 5] \endverbatim + * \verbatim im.ProcessMergeComplexNew(image1: imImage, image2: imImage, polar: boolean) -> new_image: imImage [in Lua 5] \endverbatim * \ingroup arithm */ void imProcessMergeComplex(const imImage* src_image1, const imImage* src_image2, imImage* dst_image, int polar); diff --git a/mak.vc9/im.vcproj b/mak.vc9/im.vcproj index be9af21..a42553c 100644 --- a/mak.vc9/im.vcproj +++ b/mak.vc9/im.vcproj @@ -96,6 +96,10 @@ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > <File + RelativePath="..\src\im.def" + > + </File> + <File RelativePath="..\src\im_attrib.cpp" > </File> diff --git a/mak.vc9/im_avi.vcproj b/mak.vc9/im_avi.vcproj index 0c08d8e..335500d 100644 --- a/mak.vc9/im_avi.vcproj +++ b/mak.vc9/im_avi.vcproj @@ -96,6 +96,10 @@ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > <File + RelativePath="..\src\im_avi.def" + > + </File> + <File RelativePath="..\src\im_format_avi.cpp" > </File> diff --git a/mak.vc9/im_capture.vcproj b/mak.vc9/im_capture.vcproj index 4f14e0e..ca7ab02 100644 --- a/mak.vc9/im_capture.vcproj +++ b/mak.vc9/im_capture.vcproj @@ -96,6 +96,10 @@ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > <File + RelativePath="..\src\im_capture.def" + > + </File> + <File RelativePath="..\src\im_capture_dx.cpp" > </File> diff --git a/mak.vc9/im_ecw.vcproj b/mak.vc9/im_ecw.vcproj index 6f938b3..abfcf69 100644 --- a/mak.vc9/im_ecw.vcproj +++ b/mak.vc9/im_ecw.vcproj @@ -96,6 +96,10 @@ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > <File + RelativePath="..\src\im_ecw.def" + > + </File> + <File RelativePath="..\src\im_format_ecw.cpp" > </File> diff --git a/mak.vc9/im_fftw.vcproj b/mak.vc9/im_fftw.vcproj index 0705b14..0b429b7 100644 --- a/mak.vc9/im_fftw.vcproj +++ b/mak.vc9/im_fftw.vcproj @@ -99,6 +99,10 @@ RelativePath="..\src\process\im_fft.cpp" > </File> + <File + RelativePath="..\src\im_fftw.def" + > + </File> <Filter Name="FFTW" > diff --git a/mak.vc9/im_jp2.vcproj b/mak.vc9/im_jp2.vcproj index 7ea6e57..ac36e79 100644 --- a/mak.vc9/im_jp2.vcproj +++ b/mak.vc9/im_jp2.vcproj @@ -100,6 +100,10 @@ > </File> <File + RelativePath="..\src\im_jp2.def" + > + </File> + <File RelativePath="..\src\jas_binfile.c" > </File> diff --git a/mak.vc9/im_process.vcproj b/mak.vc9/im_process.vcproj index b261cf1..f5f55ae 100644 --- a/mak.vc9/im_process.vcproj +++ b/mak.vc9/im_process.vcproj @@ -160,6 +160,10 @@ > </File> <File + RelativePath="..\src\im_process.def" + > + </File> + <File RelativePath="..\src\process\im_quantize.cpp" > </File> diff --git a/mak.vc9/im_wmv.vcproj b/mak.vc9/im_wmv.vcproj index 775fcc3..4368580 100644 --- a/mak.vc9/im_wmv.vcproj +++ b/mak.vc9/im_wmv.vcproj @@ -99,6 +99,10 @@ RelativePath="..\src\im_format_wmv.cpp" > </File> + <File + RelativePath="..\src\im_wmv.def" + > + </File> </Filter> <Filter Name="Header Files" diff --git a/mak.vc9/imlua3.vcproj b/mak.vc9/imlua3.vcproj index ae2fd2e..fd01c8b 100644 --- a/mak.vc9/imlua3.vcproj +++ b/mak.vc9/imlua3.vcproj @@ -99,6 +99,10 @@ RelativePath="..\src\im_lua3.c" > </File> + <File + RelativePath="..\src\imlua3.def" + > + </File> </Filter> <Filter Name="Header Files" diff --git a/mak.vc9/imlua5.vcproj b/mak.vc9/imlua5.vcproj index d6f9c85..4314812 100644 --- a/mak.vc9/imlua5.vcproj +++ b/mak.vc9/imlua5.vcproj @@ -100,6 +100,10 @@ > </File> <File + RelativePath="..\src\lua5\imlua.def" + > + </File> + <File RelativePath="..\src\lua5\imlua_aux.c" > </File> diff --git a/mak.vc9/imlua_capture5.vcproj b/mak.vc9/imlua_capture5.vcproj index fe38990..3037207 100644 --- a/mak.vc9/imlua_capture5.vcproj +++ b/mak.vc9/imlua_capture5.vcproj @@ -99,6 +99,10 @@ RelativePath="..\src\lua5\imlua_capture.c" > </File> + <File + RelativePath="..\src\lua5\imlua_capture.def" + > + </File> </Filter> </Files> <Globals> diff --git a/mak.vc9/imlua_fftw5.vcproj b/mak.vc9/imlua_fftw5.vcproj index 47d43f6..758bd37 100644 --- a/mak.vc9/imlua_fftw5.vcproj +++ b/mak.vc9/imlua_fftw5.vcproj @@ -103,6 +103,10 @@ RelativePath="..\src\lua5\imlua_fftw.c" > </File> + <File + RelativePath="..\src\lua5\imlua_fftw.def" + > + </File> </Filter> </Files> <Globals> diff --git a/mak.vc9/imlua_process5.vcproj b/mak.vc9/imlua_process5.vcproj index e4f1c1b..7d3897f 100644 --- a/mak.vc9/imlua_process5.vcproj +++ b/mak.vc9/imlua_process5.vcproj @@ -107,6 +107,10 @@ RelativePath="..\src\lua5\imlua_process.c" > </File> + <File + RelativePath="..\src\lua5\imlua_process.def" + > + </File> </Filter> </Files> <Globals> @@ -99,6 +99,7 @@ EXPORTS imImageLineCount imImageLineSize imImageIsBitmap + imImageGetOpenGLData imImageMatch imImageMatchColor imImageMatchColorSpace @@ -112,6 +113,7 @@ EXPORTS imImageSetAttribute imImageSetBinary imImageMakeBinary + imImageMakeGray imImageSetPalette imImageCopy imImageCopyData diff --git a/src/im_image.cpp b/src/im_image.cpp index 7acae43..80553a7 100644 --- a/src/im_image.cpp +++ b/src/im_image.cpp @@ -2,7 +2,7 @@ * \brief Image Manipulation * * See Copyright Notice in im_lib.h - * $Id: im_image.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $ + * $Id: im_image.cpp,v 1.2 2009/08/12 04:09:16 scuri Exp $ */ #include <stdlib.h> @@ -15,6 +15,7 @@ #include "im_util.h" #include "im_attrib.h" #include "im_file.h" +#include "im_convert.h" int imImageCheckFormat(int color_mode, int data_type) @@ -52,7 +53,7 @@ int imImageLineSize(int width, int color_mode, int data_type) return imImageLineCount(width, color_mode) * imDataTypeSize(data_type); } -static void iImageInit(imImage* image, int width, int height, int color_space, int data_type) +static void iImageInit(imImage* image, int width, int height, int color_space, int data_type, int has_alpha) { assert(width>0); assert(height>0); @@ -63,7 +64,7 @@ static void iImageInit(imImage* image, int width, int height, int color_space, i image->height = height; image->color_space = color_space; image->data_type = data_type; - image->has_alpha = 0; + image->has_alpha = has_alpha; image->depth = imColorModeDepth(color_space); image->line_size = image->width * imDataTypeSize(data_type); @@ -71,15 +72,20 @@ static void iImageInit(imImage* image, int width, int height, int color_space, i image->size = image->plane_size * image->depth; image->count = image->width * image->height; + int depth = image->depth+1; // add room for an alpha plane pointer, even if does not have alpha now. + if (image->data) { + /* if reallocating, preserve the data buffer */ void* data0 = image->data[0]; + free(image->data); - image->data = (void**)malloc((image->depth+1) * sizeof(void*)); // add room for alpha + image->data = (void**)malloc(depth * sizeof(void*)); + image->data[0] = data0; } else - image->data = (void**)malloc((image->depth+1) * sizeof(void*)); + image->data = (void**)malloc(depth * sizeof(void*)); } imImage* imImageInit(int width, int height, int color_space, int data_type, void* data_buffer, long* palette, int palette_count) @@ -90,7 +96,7 @@ imImage* imImageInit(int width, int height, int color_space, int data_type, void imImage* image = (imImage*)malloc(sizeof(imImage)); image->data = 0; - iImageInit(image, width, height, color_space, data_type); + iImageInit(image, width, height, color_space, data_type, 0); if (data_buffer) { @@ -119,6 +125,7 @@ imImage* imImageCreate(int width, int height, int color_space, int data_type) imImage* image = imImageInit(width, height, color_space, data_type, NULL, NULL, 0); if (!image) return NULL; + /* palette is available to BINARY, MAP and GRAY */ if (imColorModeDepth(color_space) == 1) { image->palette = (long*)malloc(256*sizeof(long)); @@ -137,6 +144,7 @@ imImage* imImageCreate(int width, int height, int color_space, int data_type) } } + /* allocate data buffer */ image->data[0] = malloc(image->size); if (!image->data[0]) { @@ -144,29 +152,11 @@ imImage* imImageCreate(int width, int height, int color_space, int data_type) return NULL; } + /* initialize data plane pointers */ for (int d = 1; d < image->depth; d++) image->data[d] = (imbyte*)(image->data[0]) + d*image->plane_size; - if ((image->color_space == IM_YCBCR || image->color_space == IM_LAB || image->color_space == IM_LUV) && - (image->data_type == IM_BYTE || image->data_type == IM_USHORT)) - { - memset(image->data[0], 0, image->plane_size); - - if (image->data_type == IM_BYTE) - { - imbyte* usdata = (imbyte*)image->data[1]; - for (int i = 0; i < 2*image->count; i++) - *usdata++ = 128; - } - else - { - imushort* usdata = (imushort*)image->data[1]; - for (int i = 0; i < 2*image->count; i++) - *usdata++ = 32768; - } - } - else - memset(image->data[0], 0, image->size); + imImageClear(image); return image; } @@ -182,6 +172,10 @@ imImage* imImageCreateBased(const imImage* image, int width, int height, int col imImage* new_image = imImageCreate(width, height, color_space, data_type); imImageCopyAttributes(image, new_image); + + if (image->has_alpha) + imImageAddAlpha(new_image); + return new_image; } @@ -213,21 +207,19 @@ void imImageReshape(imImage* image, int width, int height) old_width = width, old_height = height; - iImageInit(image, width, height, image->color_space, image->data_type); + iImageInit(image, width, height, image->color_space, image->data_type, image->has_alpha); if (old_size < image->size) { void* data0 = realloc(image->data[0], image->has_alpha? image->size+image->plane_size: image->size); if (!data0) // if failed restore the previous size - iImageInit(image, old_width, old_height, image->color_space, image->data_type); + iImageInit(image, old_width, old_height, image->color_space, image->data_type, image->has_alpha); else image->data[0] = data0; } - memset(image->data[0], 0, image->has_alpha? image->size+image->plane_size: image->size); - + /* initialize data plane pointers */ int depth = image->has_alpha? image->depth+1: image->depth; - for (int d = 1; d < depth; d++) image->data[d] = (imbyte*)image->data[0] + d*image->plane_size; } @@ -256,7 +248,30 @@ void imImageDestroy(imImage* image) void imImageClear(imImage* image) { assert(image); - memset(image->data[0], 0, image->has_alpha? image->size+image->plane_size: image->size); + + if ((image->color_space == IM_YCBCR || image->color_space == IM_LAB || image->color_space == IM_LUV) && + (image->data_type == IM_BYTE || image->data_type == IM_USHORT)) + { + memset(image->data[0], 0, image->plane_size); + + if (image->data_type == IM_BYTE) + { + imbyte* usdata = (imbyte*)image->data[1]; + for (int i = 0; i < 2*image->count; i++) + *usdata++ = 128; + } + else + { + imushort* usdata = (imushort*)image->data[1]; + for (int i = 0; i < 2*image->count; i++) + *usdata++ = 32768; + } + } + else + memset(image->data[0], 0, image->size); + + if (image->has_alpha) + memset(image->data[image->depth], 0, image->plane_size); } int imImageIsBitmap(const imImage* image) @@ -320,6 +335,124 @@ imImage* imImageClone(const imImage* image) return new_image; } +static void iImageMakeGray(imbyte *map, int count, int step) +{ + for(int i = 0; i < count; i++) + { + if (*map) + *map = 255; + map += step; + } +} + +static void iImageCopyMapAlpha(imbyte *map, imbyte *gldata, int depth, int count) +{ + gldata += depth-1; /* position at first alpha */ + for(int i = 0; i < count; i++) + { + *gldata = *map; + map++; + gldata += depth; /* skip to next alpha */ + } +} + +static void iImageExpandTranspIndex(imbyte *map, imbyte *gldata, int depth, int count, imbyte index) +{ + gldata += depth-1; /* position at first alpha */ + for(int i = 0; i < count; i++) + { + if (*map == index) + *gldata = 255; + + map++; + gldata += depth; /* skip to next alpha */ + } +} + +/* To avoid including gl.h */ +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A + +void* imImageGetOpenGLData(imImage* image, int *format) +{ + if (!imImageIsBitmap(image)) + return NULL; + + int transp_count; + imbyte* transp_index = (imbyte*)imImageGetAttribute(image, "TransparencyIndex", NULL, &transp_count); + + int glformat; + switch(image->color_space) + { + case IM_MAP: + if (image->has_alpha || transp_index) + glformat = GL_RGBA; + else + glformat = GL_RGB; + break; + case IM_RGB: + if (image->has_alpha) + glformat = GL_RGBA; + else + glformat = GL_RGB; + break; + case IM_BINARY: + default: /* IM_GRAY */ + if (image->has_alpha || transp_index) + glformat = GL_LUMINANCE_ALPHA; + else + glformat = GL_LUMINANCE; + break; + } + + int depth; + switch (glformat) + { + case GL_RGB: + depth = 3; + break; + case GL_RGBA: + depth = 4; + break; + case GL_LUMINANCE_ALPHA: + depth = 2; + break; + default: /* GL_LUMINANCE */ + depth = 1; + break; + } + + int size = image->count*depth; + imImageSetAttribute(image, "GLDATA", IM_BYTE, size, NULL); + imbyte* gldata = (imbyte*)imImageGetAttribute(image, "GLDATA", NULL, NULL); + + if (image->color_space == IM_RGB) + imConvertPacking(image->data[0], gldata, image->width, image->height, depth, IM_BYTE, 0); + else + { + memcpy(gldata, image->data[0], image->size); + + if (image->color_space == IM_MAP) + imConvertMapToRGB(gldata, image->count, depth, 1, image->palette, image->palette_count); + else if (image->color_space == IM_BINARY) + iImageMakeGray(gldata, image->count, (glformat==GL_LUMINANCE_ALPHA)? 2: 1); + + if (image->has_alpha) + iImageCopyMapAlpha((imbyte*)image->data[1], gldata, depth, image->count); + else if (transp_index) + { + int i; + for (i=0; i<transp_count; i++) + iImageExpandTranspIndex((imbyte*)image->data[0], gldata, depth, image->count, transp_index[i]); + } + } + + if (format) *format = glformat; + return gldata; +} + void imImageSetAttribute(imImage* image, const char* attrib, int data_type, int count, const void* data) { assert(image); @@ -474,6 +607,19 @@ void imImageMakeBinary(imImage *image) } } +void imImageMakeGray(imImage *image) +{ + assert(image); + + imbyte *map = (imbyte*)image->data[0]; + for(int i = 0; i < image->count; i++) + { + if (*map) + *map = 255; + map++; + } +} + static void iImageGrayCheckChange(imImage *image) { int i, do_remap = 0; diff --git a/src/lua5/imlua_capture.c b/src/lua5/imlua_capture.c index 15d52ce..59ec0fb 100644 --- a/src/lua5/imlua_capture.c +++ b/src/lua5/imlua_capture.c @@ -2,7 +2,7 @@ * \brief IM Lua 5 Binding * * See Copyright Notice in im_lib.h - * $Id: imlua_capture.c,v 1.1 2008/10/17 06:16:32 scuri Exp $ + * $Id: imlua_capture.c,v 1.2 2009/08/12 04:09:17 scuri Exp $ */ #include <string.h> @@ -92,7 +92,10 @@ static int imluaVideoCaptureConnect (lua_State *L) { imVideoCapture *vc = imlua_checkvideocapture(L, 1); int device = luaL_optint(L, 2, -1); - lua_pushnumber(L, imVideoCaptureConnect(vc, device)); + if (device == -1) + lua_pushnumber(L, imVideoCaptureConnect(vc, device)); + else + lua_pushboolean(L, imVideoCaptureConnect(vc, device)); return 1; } @@ -123,7 +126,7 @@ static int imluaVideoCaptureShowDialog (lua_State *L) int dialog = luaL_checkint(L, 2); void *parent = lua_touserdata(L, 3); - lua_pushnumber(L, imVideoCaptureShowDialog(vc, dialog, parent)); + lua_pushboolean(L, imVideoCaptureShowDialog(vc, dialog, parent)); return 1; } @@ -158,7 +161,7 @@ static int imluaVideoCaptureGetFormat (lua_State *L) int width, height; char desc[10]; - lua_pushnumber(L, imVideoCaptureGetFormat(vc, format, &width, &height, desc)); + lua_pushboolean(L, imVideoCaptureGetFormat(vc, format, &width, &height, desc)); lua_pushnumber(L, width); lua_pushnumber(L, height); lua_pushstring(L, desc); @@ -190,34 +193,50 @@ static int imluaVideoCaptureSetImageSize (lua_State *L) int width = luaL_checkint(L, 2); int height = luaL_checkint(L, 3); - lua_pushnumber(L, imVideoCaptureSetImageSize(vc, width, height)); + lua_pushboolean(L, imVideoCaptureSetImageSize(vc, width, height)); return 1; } /*****************************************************************************\ - vc:SetFormat() + vc:SetInOut() \*****************************************************************************/ -static int imluaVideoCaptureSetFormat (lua_State *L) +static int imluaVideoCaptureSetInOut(lua_State *L) { imVideoCapture *vc = imlua_checkvideocapture(L, 1); - int format = luaL_checkint(L, 2); + int input = luaL_checkint(L, 2); + int output = luaL_checkint(L, 3); + int cross = luaL_checkint(L, 4); - lua_pushnumber(L, imVideoCaptureSetFormat(vc, format)); + lua_pushboolean(L, imVideoCaptureSetInOut(vc, input, output, cross)); return 1; } /*****************************************************************************\ + vc:SetFormat() +\*****************************************************************************/ +static int imluaVideoCaptureSetFormat (lua_State *L) +{ + imVideoCapture *vc = imlua_checkvideocapture(L, 1); + int format = luaL_optint(L, 2, -1); + if (format == -1) + lua_pushnumber(L, imVideoCaptureSetFormat(vc, format)); + else + lua_pushboolean(L, imVideoCaptureSetFormat(vc, format)); + return 1; +} + +/*****************************************************************************\ vc:ResetAttribute(attrib, fauto) \*****************************************************************************/ static int imluaVideoCaptureResetAttribute (lua_State *L) { imVideoCapture *vc = imlua_checkvideocapture(L, 1); const char *attrib = luaL_checkstring(L, 2); - int fauto = luaL_checkint(L, 3); + int fauto = lua_toboolean(L, 3); - lua_pushnumber(L, imVideoCaptureResetAttribute(vc, attrib, fauto)); + lua_pushboolean(L, imVideoCaptureResetAttribute(vc, attrib, fauto)); return 1; } @@ -230,7 +249,7 @@ static int imluaVideoCaptureSetAttribute (lua_State *L) const char *attrib = luaL_checkstring(L, 2); float percent = (float) luaL_checknumber(L, 3); - lua_pushnumber(L, imVideoCaptureSetAttribute(vc, attrib, percent)); + lua_pushboolean(L, imVideoCaptureSetAttribute(vc, attrib, percent)); return 1; } @@ -243,7 +262,7 @@ static int imluaVideoCaptureGetAttribute (lua_State *L) const char *attrib = luaL_checkstring(L, 2); float percent; - lua_pushnumber(L, imVideoCaptureGetAttribute(vc, attrib, &percent)); + lua_pushboolean(L, imVideoCaptureGetAttribute(vc, attrib, &percent)); lua_pushnumber(L, percent); return 2; } @@ -282,7 +301,7 @@ static int imluaVideoCaptureFrame (lua_State *L) luaL_argerror(L, 2, "image must be of RGB or Gray color spaces"); imlua_checkdatatype(L, 2, image, IM_BYTE); - lua_pushnumber(L, imVideoCaptureFrame(vc, image->data[0], image->color_space, timeout)); + lua_pushboolean(L, imVideoCaptureFrame(vc, image->data[0], image->color_space, timeout)); return 1; } @@ -299,7 +318,7 @@ static int imluaVideoCaptureOneFrame (lua_State *L) luaL_argerror(L, 2, "image must be of RGB or Gray color spaces"); imlua_checkdatatype(L, 2, image, IM_BYTE); - lua_pushnumber(L, imVideoCaptureOneFrame(vc, image->data[0], image->color_space)); + lua_pushboolean(L, imVideoCaptureOneFrame(vc, image->data[0], image->color_space)); return 1; } @@ -310,9 +329,11 @@ static int imluaVideoCaptureOneFrame (lua_State *L) static int imluaVideoCaptureLive (lua_State *L) { imVideoCapture *vc = imlua_checkvideocapture(L, 1); - int live = luaL_checkint(L, 2); - - lua_pushnumber(L, imVideoCaptureLive(vc, live)); + int live = luaL_optint(L, 2, -1); + if (live == -1) + lua_pushnumber(L, imVideoCaptureLive(vc, live)); + else + lua_pushboolean(L, imVideoCaptureLive(vc, live)); return 1; } @@ -377,6 +398,7 @@ static const luaL_reg imcapture_metalib[] = { {"SetFormat", imluaVideoCaptureSetFormat}, {"GetImageSize", imluaVideoCaptureGetImageSize}, {"SetImageSize", imluaVideoCaptureSetImageSize}, + {"SetInOut", imluaVideoCaptureSetInOut}, {"ResetAttribute", imluaVideoCaptureResetAttribute}, {"GetAttribute", imluaVideoCaptureGetAttribute}, {"SetAttribute", imluaVideoCaptureSetAttribute}, diff --git a/src/lua5/imlua_image.c b/src/lua5/imlua_image.c index 22ed38c..dc3322a 100644 --- a/src/lua5/imlua_image.c +++ b/src/lua5/imlua_image.c @@ -2,7 +2,7 @@ * \brief IM Lua 5 Binding * * See Copyright Notice in im_lib.h - * $Id: imlua_image.c,v 1.1 2008/10/17 06:16:32 scuri Exp $ + * $Id: imlua_image.c,v 1.2 2009/08/12 04:09:17 scuri Exp $ */ #include <string.h> @@ -437,6 +437,28 @@ static int imluaImageIsBitmap (lua_State *L) return 1; } + +/*****************************************************************************\ + image:GetOpenGLData() +\*****************************************************************************/ +static int imluaImageGetOpenGLData (lua_State *L) +{ + int format; + imbyte* gldata; + imImage *image = imlua_checkimage(L, 1); + + gldata = imImageGetOpenGLData(image, &format); + if (!gldata) + { + lua_pushnil(L); + return 1; + } + + lua_pushlightuserdata(L, gldata); + lua_pushinteger(L, format); + return 2; +} + /*****************************************************************************\ image:GetPalette() \*****************************************************************************/ @@ -551,6 +573,15 @@ static int imluaImageMakeBinary (lua_State *L) } /*****************************************************************************\ + image:MakeGray() +\*****************************************************************************/ +static int imluaImageMakeGray (lua_State *L) +{ + imImageMakeGray(imlua_checkimage(L, 1)); + return 0; +} + +/*****************************************************************************\ image:Width() \*****************************************************************************/ static int imluaImageWidth(lua_State *L) @@ -965,6 +996,7 @@ static const luaL_reg imimage_metalib[] = { {"GetAttributeList", imluaImageGetAttributeList}, {"Clear", imluaImageClear}, {"IsBitmap", imluaImageIsBitmap}, + {"GetOpenGLData", imluaImageGetOpenGLData}, {"SetPalette", imluaImageSetPalette}, {"GetPalette", imluaImageGetPalette}, {"CopyAttributes", imluaImageCopyAttributes}, @@ -975,6 +1007,7 @@ static const luaL_reg imimage_metalib[] = { {"Match", imluaImageMatch}, {"SetBinary", imluaImageSetBinary}, {"MakeBinary", imluaImageMakeBinary}, + {"MakeGray", imluaImageMakeGray}, {"Width", imluaImageWidth}, {"Height", imluaImageHeight}, {"Depth", imluaImageDepth}, diff --git a/src/lua5/imlua_process.c b/src/lua5/imlua_process.c index 492a1ba..1c0dfc8 100644 --- a/src/lua5/imlua_process.c +++ b/src/lua5/imlua_process.c @@ -2,7 +2,7 @@ * \brief IM Lua 5 Binding * * See Copyright Notice in im_lib.h - * $Id: imlua_process.c,v 1.5 2009/08/04 21:35:26 scuri Exp $ + * $Id: imlua_process.c,v 1.6 2009/08/12 04:09:17 scuri Exp $ */ #include <memory.h> @@ -77,7 +77,7 @@ static int imluaCalcHistogram (lua_State *L) { imImage* src_image = imlua_checkimage(L, 1); int plane = luaL_checkint(L, 2); - int cumulative = luaL_checkint(L, 3); + int cumulative = lua_toboolean(L, 3); switch (src_image->data_type) { @@ -112,7 +112,7 @@ static int imluaCalcGrayHistogram (lua_State *L) { unsigned long hist[256]; imImage* src_image = imlua_checkimage(L, 1); - int cumulative = luaL_checkint(L, 2); + int cumulative = lua_toboolean(L, 2); imlua_checkdatatype(L, 1, src_image, IM_BYTE); if (src_image->color_space >= IM_CMYK) @@ -1679,7 +1679,7 @@ static int imluaProcessMergeComplex (lua_State *L) imImage *src_image1 = imlua_checkimage(L, 1); imImage *src_image2 = imlua_checkimage(L, 2); imImage *dst_image = imlua_checkimage(L, 3); - int polar = luaL_checkint(L, 5); + int polar = lua_toboolean(L, 4); imlua_checkdatatype(L, 1, src_image1, IM_FLOAT); imlua_checkdatatype(L, 2, src_image2, IM_FLOAT); |