📄 lvjpeg.h
字号:
/* *
* LEUTRON VISION SUPPLEMENTAL LIBRARY FOR CONVERSION BETWEEN *
* IN-MEMORY WINDOWS DEVICE INDEPENDENT BITMAP AND JPEG FILE *
* */
#ifndef LVJPEG_H
#define LVJPEG_H
#include <windows.h>
#if defined(__cplusplus)
#define DLLENTRY extern "C" __declspec(dllexport)
#else
#define DLLENTRY __declspec(dllexport)
#endif
#define LV_DCT_DEFAULT 0
#define LV_DCT_FAST 1
#define LV_DCT_FLOAT 2
DLLENTRY BOOL WINAPI LvJpg_SaveBmpToJpgFile (BITMAPINFO* pBmpInfo,
BYTE* pBmpData,
const char* szFileName,
int iQualityFactor,
int iDctMethod);
DLLENTRY BOOL WINAPI LvJpg_LoadBmpFromJpgFile (BITMAPINFO* pBmpInfo,
BYTE* pBmpData,
const char* szFileName,
DWORD* pdwDataSize);
DLLENTRY void WINAPI LvJpg_GetLastErrorMessage (char* szMessage, int iMaxLength);
#endif
/*
BRIEF GUIDE
===============================================================================
DLLENTRY BOOL WINAPI LvJpg_SaveBmpToJpgFile (BITMAPINFO* pBmpInfo,
BYTE* pBmpData,
const char* szFileName,
int iQualityFactor,
int iDctMethod);
Description:
-----------
Compresses image from Windows Device Independent Bitmap and
saves it to the specified file.
Supported formats:
8-bit (always saved as greyscaled)
15-bit, 16-bit, 24-bit, 32-bit uncompressed
Parameters:
----------
BITMAPINFO* pBmpInfo ...... Pointer to valid bitmap info structure.
BYTE* pBmpData ............ Pointer to image data.
const char* szFileName .... Name of the file (full path recommended).
int iQualityFactor ........ Quality in range from 1 to 255,
1 is the worst, 255 the best.
int iDctMethod ............ LV_DCT_DEFAULT - slow, but accurate
LV_DCT_FAST - fast, but less accurate
LV_DCT_FLOAT - using floating point math,
accurate and maybe the fastest
Return value:
------------
TRUE if successful, FALSE if not - in such case call the
LvJpg_GetLastErrorMessage to get the error description.
-------------------------------------------------------------------------------
DLLENTRY BOOL WINAPI LvJpg_LoadBmpFromJpgFile (BITMAPINFO* pBmpInfo,
BYTE* pBmpData,
const char* szFileName,
DWORD* pdwDataSize);
Description:
-----------
Reads JPEG file and decompresses the image to the Windows Device Independent
Bitmap format.
Supported formats:
Greyscale images are stored in 8-bit/pixel format,
color images in 24-bit/pixel format.
Parameters:
----------
BITMAPINFO* pBmpInfo ...... Pointer to bitmap info structure.
This stucture is filled after the JPEG header
is read. Can be NULL.
BYTE* pBmpData ............ Pointer to image data. Can be NULL - in such case
only the JPEG header is read in order to fill the
pBmpInfo and pdwDataSize. It is your responsibility
to allocate sufficiently large buffer and supply
it to this function.
const char* szFileName .... Name of the file (full path recommended).
DWORD* pdwDataSize ........ Returns size of the buffer that needs to be
allocated for image data (pBmpData). Can be NULL.
Typical usage: Call this function twice: First with pBmpData set NULL to obtain
bitmap info and/or bitmap data size. Then allocate buffer for image data and call
the function the second time for image decompression.
Example:
DWORD dwSize;
pBmpInfoHeader = (BITMAPINFOHEADER*) GlobalAlloc(GPTR,
sizeof(BITMAPINFOHEADER) + 256*sizeof(RGBQUAD));
if (LvJpg_LoadBmpFromJpgFile ((BITMAPINFO*) pBmpInfoHeader,
NULL,
"C:\\Test\\Test.jpg",
&dwSize))
{
pBmpData = (BYTE*) GlobalAlloc(GPTR, dwSize);
LvJpg_LoadBmpFromJpgFile ((BITMAPINFO*) pBmpInfoHeader,
pBmpData,
"C:\\Test\\Test.jpg",
NULL);
}
Return value:
------------
TRUE if successful, FALSE if not - in such case call the
LvJpg_GetLastErrorMessage to get the error description.
-------------------------------------------------------------------------------
DLLENTRY void WINAPI LvJpg_GetLastErrorMessage (char* szMessage, int iMaxLength);
Description:
-----------
Returns last error message..
Parameters:
----------
char* szMessage ........... Buffer for the returned message.
int iMaxLength ............ Maximum message length
(should be the buffer size - 1).
===============================================================================
This DLL was programmed using the Independent JPEG Group's JPEG Library
===============================================================================
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -