⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lvimgproc.h

📁 相机传输图像程序源代码 拜耳模式(RAW格式文件)与RGB图像数据互相转换函数库
💻 H
📖 第 1 页 / 共 5 页
字号:
#ifndef LvImgProcH
#define LvImgProcH

#include <windows.h>

#if defined(__cplusplus)
  #define LVIP_DLLENTRY extern "C" 
#else
  #define LVIP_DLLENTRY 
#endif

#ifndef U8BIT
  #define U8BIT BYTE
#endif

#ifndef U16BIT
  #define U16BIT WORD
#endif

#ifndef U32BIT
  #define U32BIT DWORD
#endif

#ifndef S32BIT
  #define S32BIT int
#endif


/** @defgroup PixelFormats Pixel formats definition. */
//@{
/** 8-bit MONO image pixel format.
 * Image is in 256 levels of grey.
 */
#define LVIP_PIXEL_FORMAT_MONO8      8
/** 9-bit MONO image pixel format.
 * Image is in 512 levels of grey (monochrome image).
 */
#define LVIP_PIXEL_FORMAT_MONO9   1009
/** 10-bit MONO image pixel format.
 * Image is in 1024 levels of grey (monochrome image).
 */
#define LVIP_PIXEL_FORMAT_MONO10  1010
/** 11-bit MONO image pixel format.
 * Image is in 2048 levels of grey (monochrome image).
 */
#define LVIP_PIXEL_FORMAT_MONO11  1011
/** 12-bit MONO image pixel format.
 * Image is in 4096 levels of grey (monochrome image).
 */
#define LVIP_PIXEL_FORMAT_MONO12  1012
/** 13-bit MONO image pixel format.
 * Image is in 8192 levels of grey (monochrome image).
 */
#define LVIP_PIXEL_FORMAT_MONO13  1013
/** 14-bit MONO image pixel format.
 * Image is in 16384 levels of grey (monochrome image).
 */
#define LVIP_PIXEL_FORMAT_MONO14  1014
/** 15-bit MONO image pixel format.
 * Image is in 32768 levels of grey (monochrome image).
 */
#define LVIP_PIXEL_FORMAT_MONO15  1015
/** 16-bit MONO image pixel format.
 * Image is in 65536 levels of grey (monochrome image).
 */
#define LVIP_PIXEL_FORMAT_MONO16  1016
/** 15-bit RGB image pixel format.
 * Each pixel is composed using 5 bits for the Red component, 5 bits for Green and 5 bits for Blue.
 */
#define LVIP_PIXEL_FORMAT_RGB555_PACKED     15
/** 16-bit RGB image pixel format.
 * Each pixel is composed using 5 bits for the Red component, 6 bits for Green and 5 bits for Blue.
 */
#define LVIP_PIXEL_FORMAT_RGB565_PACKED     16
/** 24-bit RGB image pixel format.
 * Each pixel is composed using 8 bits for the Red component, 8 bits for Green and 8 bits for Blue.
 */
#define LVIP_PIXEL_FORMAT_RGB8_PACKED     24
/** 32-bit RGB image pixel format.
 * Each pixel is composed using 8 bits for the Red component, 8 bits for Green, 8 bits for Blue and 8 bits for the Alpha channel.
 */
#define LVIP_PIXEL_FORMAT_RGBA8_PACKED     32
/** 24-bit BGR image pixel format.
 * This pixel format has reversed the order of the RGB components; it is required for saving to the TIFF format.\n
 * Each pixel is composed using 8 bits for the Red component, 8 bits for Green and 8 bits for Blue.
 */
#define LVIP_PIXEL_FORMAT_BGR8_PACKED   2024
/** 48-bit RGB image pixel format.
 * Each pixel is composed using 16 bits for the Red component, 16 bits for Green and 16 bits for Blue.
 * This format is used for high precision processing of color images.
 */
#define LVIP_PIXEL_FORMAT_RGB16_PACKED     48
//@}

/** @defgroup ImageFlags Image flags definition. */
//@{
/** The RGB components of the color image are stored in color planes,
 *  that means that each color plane is stored in a separate buffer
   * For example 4x3 24bit RGB picture \b without color planes looks like:
   * @code
   *   pData  -> RGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGBRGB
   * @endcode
   * but 4x3 24bit RGB picture \b with color planes looks like:
   * @code
   *   pDataR -> RRRRRRRRRRRR
   *   pDataG -> GGGGGGGGGGGG
   *   pDataB -> BBBBBBBBBBBB
   * @endcode 
 */
#define LVIP_IMG_ATTR_COLOR_PLANES            0x00000001ul
/** Lines in the image buffer are ordered from the bottom line to the top line,
 * so the buffer contents of the image of width=W x height=H is the following:
 * @code
 *   pixel[H,1], pixel[H,2], pixel[H,3] ... pixel[H,W],
 *   pixel[H-1,1], pixel[H-1,2], pixel[H-1,3], ... pixel[H-1,W],
 *   ...
 *   pixel[1,1], pixel[1,2], pixel[1,3], ... pixel[1,W],
 * @endcode
 */
#define LVIP_IMG_ATTR_BOTTOM_UP               0x00000002ul

/** Red lenses in the Bayer array are on odd lines, when lines are numbered from 0
 * (0 = even line, 1 = odd line, 2 = even line...). This flag is used by the @ref FunctionsBayer.
 */
#define LVIP_IMG_ATTR_BAYER_RED_ON_ODD_LINES  0x00000010ul

/** Red lenses in the Bayer array are on odd columns, when columns are numbered from 0
 * (0 = even column, 1 = odd column, 2 = even column...) This flag is used by the @ref FunctionsBayer.
 */
#define LVIP_IMG_ATTR_BAYER_RED_ON_ODD_COLS   0x00000020ul

/** The @ref lvip_ImgInfo is not the owner of image data, so the
 * lvip_DeallocateImageData() function will not attempt to deallocate the image data.
 * This flag is used when the image data are owned by another @ref lvip_ImgInfo or belonging
 * to other code, for example when working directly with the image in the DMA buffer.
 * Note that lvip_DeallocateImageData() may be called from other functions, for example, when you
 * use the @ref LVIP_IMG_REALLOCATE_DST flag.
 */
#define LVIP_IMG_ATTR_NOT_DATA_OWNER     0x00000800ul

/* for internal use only - mask for all image attributes*/
#define LVIP_IMG_ATTR_MASK  (LVIP_IMG_ATTR_COLOR_PLANES | LVIP_IMG_ATTR_BOTTOM_UP | LVIP_IMG_ATTR_BAYER_RED_ON_ODD_LINES | LVIP_IMG_ATTR_BAYER_RED_ON_ODD_COLS | LVIP_IMG_ATTR_NOT_DATA_OWNER)

/** The line increment is aligned to double word (32 bits).
 * This is required by the Windows Device Independent Bitmap format (DIB, BMP)
 * This flag is used only in the lvip_InitImgInfo() function.
 */
#define LVIP_IMG_DWORD_ALIGNED           0x00000004ul

/** The line increment is aligned to double word (64 bits).
 * This flag is used in the lvip_InitImgInfo() function (which can be called as a result 
 * of the LVIP_IMG_REALLOCATE_DST flag).
 */
#define LVIP_IMG_QWORD_ALIGNED           0x00000008ul

/** The destination image data could be reallocated if it is needed.
 * If the function stores a result of the operation to the destination image buffer, it first checks
 * if the destination @ref lvip_ImgInfo has appropriate parameters and the buffer(s) allocated.
 * If not and this flag is specified, it adapts the parameters of the @ref lvip_ImgInfo and reallocates the buffer as needed.
 * If this flag is not specified, the function returns an error in case of mismatch.
 */
#define LVIP_IMG_REALLOCATE_DST          0x00001000ul

//@}

/** @defgroup SaveLoadFlags Flags used when saving or loading images. */
//@{

/** The flag will force conversion of the image to 16-bit mono format, if it is in 9- to 15-bit mono format.
 * This can be used used when saving mono image to TIFF by the lvip_SaveToTiff() function, as many software packages
 * do not understand mono TIFF if it is in 9- to 15-bit mono format.
 */
#define LVIP_IMG_TIFF_CONVERT_TO_16BIT   0x00002000ul

/** The BMP file will be read to the top-down line layout. This flag is used in the lvip_LoadFromBmp()
 * and lvip_SaveToBmp() functions, as the BMP format can be either in the bottom-up line layout or in the top-down line layout.
 */
#define LVIP_IMG_BMP_FORCE_TOP_DOWN      0x00004000ul

/** The BMP file will be read to the bottom-up line layout. This flag is used in the lvip_LoadFromBmp()
 * and lvip_SaveToBmp() functions, as the BMP format can be either in the bottom-up line layout or in the top-down line layout.
 */
#define LVIP_IMG_BMP_FORCE_BOTTOM_UP     0x00008000ul

//@}

/** @defgroup SharpeningFlags Flags for sharpening method. */
//@{
/** Flag used in the lvip_Set3x3MatrixSharpening() function. When used, the 3x3 convolution matrix
 * for the sharpening will have weights for all 8 neighbouring pixels. When not used, the matrix will have
 * the corner values set to 0 (lvip_Apply3x3Convolution() runs faster with such convolution matrices).
 */
#define LVIP_FUNCT_8NEIGHBOURS_SHARPENING  0x00000001ul
//@}

/** Image Info structure.
 * Each image handled by the library must be described by the lvip_ImgInfo structure.\n
 * Although you can set the Image Info members directly, it is highly recommended
 * to use the lvip_InitImgInfo() function for the structure initialization.
 */   
typedef struct
{
  /** Size of image info structure.
   * Should be set to the sizeof(lvip_ImgInfo). This member may be used in 
   * the future versions for the compatibility check.
   */
  U32BIT dwSize;
  /** Width of the image in pixels. */
  U32BIT dwWidth;
  /** Height of the image in pixels. */
  U32BIT dwHeight;
  /** Pixel format of the image which is saved in this structure.
   * One of the @ref PixelFormats "pixel format"\n
   * In case of color planes (see the @ref LVIP_IMG_ATTR_COLOR_PLANES flag) the pixel format applies to one plane, so use
   * only the MONO formats for the planes. For example for 3x8-bit RGB use the @ref LVIP_PIXEL_FORMAT_MONO8 format.
   */
  U32BIT dwPixelFormat;
  /** Flags indicating image attributes.
   * OR-ed definitions from @ref ImageFlags definitions (only the with LVIP_IMG_ATTR_xxx flags).
   */
  U32BIT dwImgFlags;
  /** Size of one pixel in bytes.
   * @code
   *   8-bit mono image has dwPixelIncrement = 1
   *   24-bit RGB image has dwPixelIncrement = 3
   *   ...
   * @endcode
   */
  U32BIT dwPixelIncrement;
  /** Size of one line in bytes.\n
   * Example:
   * @code
   *   8-bit mono image: dwLineIncrement = dwWidth;
   *   24-bit RGB image: dwLineIncrement = dwWidth * 3;
   * @endcode
   * However, when the @ref LVIP_IMG_DWORD_ALIGNED flag is used, the line increment must be rounded up
   * to whole double-words, so the calculation would then look like this:
   * @code
   *   8-bit mono image: dwLineIncrement = (dwWidth+3)/4 * 4;
   *   24-bit RGB image: dwLineIncrement = ((dwWidth*3)+3)/4 * 4;
   * @endcode
   */
  U32BIT dwLineIncrement;
  /** Pointer to image data.
   * If the @ref LVIP_IMG_ATTR_COLOR_PLANES flag is not set, this member points to the data of the image.
   * Use lvip_AllocateImageData() to allocate the buffer for the image. If you set the pointer to an existing image,
   * which is not owned by this @ref lvip_ImgInfo, use the @ref LVIP_IMG_ATTR_NOT_DATA_OWNER flag.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -