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

📄 orchid_u.pas

📁 相机传输图像程序源代码 拜耳模式(RAW格式文件)与RGB图像数据互相转换函数库
💻 PAS
字号:
// LEUTRON VISION ORCHID_U.DLL - include file for Delphi 2.0 and higher
// This DLL contains various useful utilities which might help with bitmap manipulations etc.

unit Orchid_U;

interface

uses Windows;

const LVXBMP_PRESERVE_LUMINANCE = 1;
const LVXBMP_HIGHLIGHT          = 2;
const LVXBMP_MIDTONES           = 4;
const LVXBMP_SHADOWS            = 8;

const LVXBMP_SETTINGS_BUFFER_SIZE = 1068;

//------------------------------------------------------------------------------
// Returns the pixel value as COLORREF from a bitmap
// COLORREF in Win32 defines the colors as 0x00bbggrr
  function  lvx_BmpGetPixel (pBmpInfo: PBitmapInfo; pBmpData: PByte;
                             iXPos: integer; iYPos: integer): COLORREF; stdcall;

//------------------------------------------------------------------------------
// Paints the bitmap in the specified window.
// The iClipFrame defines the thickness of an "invisible frame" which cuts of edges of the image.
// Set iClipFrame to 0, if you do not want to use this feature.

  procedure lvx_BmpDisplay (pBmpInfo: PBitmapInfo; pBmpData: PByte;
                            hWindow: HWND; iClipFrame: integer); stdcall;

// the same function, but places the bitmap always to top-left corner

  procedure lvx_BmpDisplayTopLeft (pBmpInfo: PBitmapInfo; pBmpData: PByte;
                                   hWindow: HWND; iClipFrame: integer); stdcall;

//------------------------------------------------------------------------------
// Paints the bitmap in the specified window scaled/streched by Windows GDI to fit in the window.
// The iClipFrame defines the thickness of an "invisible frame" which reduces the size of the image.
// Set iClipFrame to 0, if you do not want to use this feature
// If bKeepAspectRatio is TRUE, the image is painted with the preserved aspect ratio, with possible
// vertical or horizontal stripes around the image in case the window dows not have its client area
// in the same aspect ratio.

  procedure lvx_BmpDisplayStretch (pBmpInfo: PBitmapInfo; pBmpData: PByte;
                                   hWindow: HWND; iClipFrame: integer;
                                   bKeepAspectRatio: LongBool); stdcall;

//------------------------------------------------------------------------------
// Returns the size of single line in bytes.

  function  lvx_BmpGetLineIncrement (pBmpInfo: PBitmapInfo): integer; stdcall;

//------------------------------------------------------------------------------
// Returns the width of the bitmap.

  function  lvx_BmpGetWidth (pBmpInfo: PBitmapInfo): integer; stdcall;

//------------------------------------------------------------------------------
// Returns the height of the bitmap as positive value, regardless whether the bitmap
// is top-down or bottom-up
  function  lvx_BmpGetHeight (pBmpInfo: PBitmapInfo): integer; stdcall;

//------------------------------------------------------------------------------
// Returns the number of bits per pixel of the bitmap.
  function  lvx_BmpGetBitCount (pBmpInfo: PBitmapInfo): integer; stdcall;

//------------------------------------------------------------------------------
// Returns TRUE if the bitmap is top-down oriented, or FALSE if it is bottom-up
  function  lvx_BmpIsTopDown (pBmpInfo: PBitmapInfo): LongBool; stdcall;

//------------------------------------------------------------------------------
// Reverses the order of lines, making from top-down the bottom-up or vice versa
// Changes also the height value to negative/positive

  function  lvx_BmpReverseLines (pBmpInfo: PBitmapInfo; pBmpData: PByte): LongBool; stdcall;

//------------------------------------------------------------------------------
// Deinterlaces the bitmap by averaging each 2 lines. This function is significantly slower
// in 15/16 bit format than in 8-, 24- and 32-bit format

  procedure lvx_BmpDeinterlace (pBmpInfo: PBitmapInfo; pBmpData: PByte); stdcall;

//-----------------------------------------------------------------------------
// Mirrors the image along vertical axis (bLeftRightMirror) and/or the 
// horizontal axis (bTopDownMirror). The destination bitmap data pointer 
// (pDstBmpData) can be the same as the source bitmap (pSrcBmpData).

  function  lvx_BmpMirror (pSrcBmpInfo: PBitmapInfo; pSrcBmpData: PByte; pDstBmpData: PByte;
                           bTopDownMirror: LongBool; bLeftRightMirror: LongBool): LongBool; stdcall;

//------------------------------------------------------------------------------
// Rotates the bitmap by 90 degrees either clockwise or counterclockwise.
// Reallocates pDstBmpData and pDstBmpInfo if needed. Allocation is done
// with the GMEM_FIXED option, so there is no need to lock/unlock allocated
// memory. The caller is resposible for calling GlobalFree() when the bitmap is
// no longer used.

  function  lvx_BmpRotate (pSrcBmpInfo: PBitmapInfo; pSrcBmpData: PByte;
                           var pDstBmpInfo: PBitmapInfo; var pDstBmpData: PByte;
                           bClockWise: LongBool): LongBool; stdcall;

//--------------------------------------------------------------------------------------
// Mirrors the bitmap and then rotates it.
// Reallocates pDstBmpData and pDstBmpInfo if needed. Allocation is done
// with the GMEM_FIXED option, so there is no need to lock/unlock allocated
// memory. The caller is resposible for calling GlobalFree() when the bitmap is
// no longer used. 

  function  lvx_BmpMirrorAndRotate (pSrcBmpInfo: PBitmapInfo; pSrcBmpData: PByte;
                                    var pDstBmpInfo: PBitmapInfo; var pDstBmpData: PByte;
                                    bTopDownMirror: LongBool; bLeftRightMirror: LongBool; 
                                    bClockWise: LongBool): LongBool; stdcall;

//------------------------------------------------------------------------------
// Extracts a rectangle from a bitmap and returns it as a new bitmap.
// Reallocates pDstBmpData and pDstBmpInfo if needed. Allocation is done
// with the GMEM_FIXED option, so there is no need to lock/unlock allocated
// memory. The caller is resposible for calling GlobalFree() when the bitmap is
// no longer used.

  function  lvx_BmpGetAreaAsBitmap (pSrcBmpInfo: PBitmapInfo; pSrcBmpData: PByte;
                                    var pDstBmpInfo: PBitmapInfo; var pDstBmpData: PByte;
                                    iDstXOffset: integer; iDstYOffset: integer;
                                    iDstWidth: integer; iDstHeight: integer): LongBool; stdcall;

//------------------------------------------------------------------------------
// Loads the bitmap from file. Allocates single buffer in global heap, containing both BmpInfo and
// BmpData. The user's resposibility is to deallocate the buffer after use - deallocate only the
// pBmpInfo, not pBmpData. Deallocate by GlobalFree(pBmpInfo) without using GlobalUnlock
// (allocation is done with GMEM_FIXED option).
// Does not support less than 8 bits per pixel color format.

  function  lvx_BmpLoadFromFile (szFileName: PChar; var pBmpInfo: PBitmapInfo; var pBmpData: PByte): LongBool; stdcall;

//------------------------------------------------------------------------------
// Saves the bitmap to a file.
// Does not support less than 8 bits per pixel color format.

  function  lvx_BmpSaveToFile (szFileName: PChar; pBmpInfo: PBitmapInfo; pBmpData: PByte): LongBool; stdcall;

//------------------------------------------------------------------------------
// Copies the bitmap to clipboard.
// Does not support less than 8 bits per pixel color format.

  function  lvx_BmpCopyToClipboard(pBmpInfo: PBitmapInfo; pBmpData: PByte): LongBool; stdcall;

//------------------------------------------------------------------------------
// Applies RGB color correction to the image. The image must be in 24-bit or 32-bit color
// format. The source image can be the same as the destination image. If it is not the
// same, the destination pDstBmpData must point to properly allocated bufer of size
// lvx_BmpGetLineIncrement * lvx_BmpGetHeight.

// iRedCorrection   = value in range -50 to 50, zero means no correction in red channel
// iGreenCorrection = value in range -50 to 50, zero means no correction in green channel
// iBlueCorrection  = value in range -50 to 50, zero means no correction in blue channel

// dwSettings: OR-ed combination of the following flags:
// LVXBMP_PRESERVE_LUMINANCE - the luminance of the pixel is preserved
// LVXBMP_HIGHLIGHT          - color correction is applied to light pixels
// LVXBMP_MIDTONES           - color correction is applied to middle-intensity pixels
// LVXBMP_SHADOWS            - color correction is applied to dark pixels

// void* pSettingsBuffer - pointer to a buffer of LVXBMP_SETTINGS_BUFFER_SIZE size.
// This buffer holds calculated parameters, so that they are not needed to be
// recalculated each time the function is called.
// If this buffer is NULL, the parameters are recalculated each time the function
// is called.

  function  lvx_BmpRgbColorCorrection (pBmpInfo: PBitmapInfo; pSrcBmpData: PByte; pDstBmpData: PByte;
                                       iRedCorrection: integer; iGreenCorrection: integer; iBlueCorrection: integer;
                                       dwSettings: DWORD; pSettingsBuffer: PByte): LongBool; stdcall;

//------------------------------------------------------------------------------


implementation

  function  lvx_BmpGetPixel                  ; external 'Orchid_U.dll';
  procedure lvx_BmpDisplay                   ; external 'Orchid_U.dll';
  procedure lvx_BmpDisplayTopLeft            ; external 'Orchid_U.dll';
  procedure lvx_BmpDisplayStretch            ; external 'Orchid_U.dll';
  function  lvx_BmpGetLineIncrement          ; external 'Orchid_U.dll';
  function  lvx_BmpGetWidth                  ; external 'Orchid_U.dll';
  function  lvx_BmpGetHeight                 ; external 'Orchid_U.dll';
  function  lvx_BmpGetBitCount               ; external 'Orchid_U.dll';
  function  lvx_BmpIsTopDown                 ; external 'Orchid_U.dll';
  function  lvx_BmpReverseLines              ; external 'Orchid_U.dll';
  procedure lvx_BmpDeinterlace               ; external 'Orchid_U.dll';
  function  lvx_BmpMirror                    ; external 'Orchid_U.dll';
  function  lvx_BmpRotate                    ; external 'Orchid_U.dll';
  function  lvx_BmpMirrorAndRotate           ; external 'Orchid_U.dll';
  function  lvx_BmpGetAreaAsBitmap           ; external 'Orchid_U.dll';
  function  lvx_BmpLoadFromFile              ; external 'Orchid_U.dll';
  function  lvx_BmpSaveToFile                ; external 'Orchid_U.dll';
  function  lvx_BmpCopyToClipboard           ; external 'Orchid_U.dll';
  function  lvx_BmpRgbColorCorrection        ; external 'Orchid_U.dll';


end.

⌨️ 快捷键说明

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