📄 jpeglibpalm.h
字号:
/*
* JpegLib.h
* Version 1.0 030714
*
* Copyright 2003, Yves Piguet. All rights reserved.
* Library based on the work of the Independent JPEG Group.
*/
/* USAGE
Install: upload JpegLib.prc to the handheld. Nothing to be linked with the application.
Global:
UInt16 jpegLibRef;
Once at startup:
Err error = SysLibFind(jpegLibName, &jpegLibRef);
if (error)
error = SysLibLoad(sysResTLibrary, jpegLibCreator, &jpegLibRef);
if (!error)
error = JpegLibOpen(jpegLibRef, jpegLibCurrentVersion);
Once at shutdown:
UInt16 usecount;
Err error = JpegLibClose(jpegLibRef, &usecount);
if (error == errNone && usecount == 0)
SysLibRemove(jpegLibRef);
Encoding:
JpegLibImageDescr image;
JpegLibData dest;
JpegLibEncodeOptions eopt;
JpegLibCreateImageDescrPtr(jpegLibRef, &image, width, height, nComponents, p);
JpegLibCreateDataHandle(jpegLibRef, &dest, jpeg); // for jpeg stored in MemHandle
JpegLibCreateDataFileStreaming(jpegLibRef, &dest, fileHandle); // for jpeg written with file streaming
JpegLibCreateDataVFS(jpegLibRef, fileRef); // for jpeg written to a VFS file
JpegLibCreateEncOptions(jpegLibRef, &eopt); // initialize options with def. values
JpegLibSetEncOptQuality(jpegLibRef, &eopt, quality); // 0 = worst .. 100 = best
JpegLibSetEncOptProgressive(jpegLibRef, &eopt, isProgressive); // 0 or 1
Err error = JpegLibWrite(jpegLibRef,
&image, // image descriptor
&eopt, // encoding options, or NULL for default settings
&dest);
Decoding (only one of JpegLibCreateData* should be called):
UInt16 w, h, nc;
JpegLibData src;
JpegLibDecodeOptions dopt;
JpegLibCreateDataHandle(jpegLibRef, src, jpeg); // for jpeg stored in MemHandle
JpegLibCreateSrcPtr(jpegLibRef, jpegP, jpegSize); // for jpeg stored in locked memory
JpegLibCreateSrcFileStreaming(jpegLibRef, fileHandle); // for jpeg read with file streaming
JpegLibCreateSrcVFS(jpegLibRef, fileRef); // for jpeg read from a VFS file
JpegLibCreateDecOptions(jpegLibRef, &dopt);
// initialize options with def. values (result -> MemHandle)
JpegLibSetDecOptDestHandle(refnum, dopt); // change output to a new MemHandle
JpegLibSetDecOptDestBitmap(refnum, dopt) // change output to a new BitmapPtr
JpegLibSetDecOptForceBW(refnum, dopt); // force grayscale output
JpegLibSetDecOptScale(refnum, dopt, scale); // reduce output size (scale must be 1/2/4/8)
Err error = JpegLibRead(jpegLibRef,
&src, // source of the jpeg
&dopt, // decoding options, or NULL for default settings
&w, &h, // image size
&nc, // number of components (1=grayscale, 3=RGB)
(void *)&result); // decoded image (BitmapPtr* or MemHandle*, depends on dopt)
*/
#if !defined(_JpegLibPalm_h)
#define _JpegLibPalm_h
#ifdef __cplusplus
extern "C" {
#endif
#include <PalmOS.h>
#include <VFSMgr.h>
#define jpegLibName "JpegLib"
#define jpegLibCreator 'JpgL'
#define jpegLibCurrentVersion 100
#define jpegErrorLibTooOld (appErrorClass | 1000)
#define jpegErrorLibTooRecent (appErrorClass | 1001)
#define jpegErrorInvalidDataType (appErrorClass | 1002)
#define jpegErrorInvalidImageDescr (appErrorClass | 1003)
#define jpegErrorFunWrite (appErrorClass | 1004)
#define jpegErrorFunRead (appErrorClass | 1005)
typedef UInt32 (*JpegLibReadFun)(void *clientData, UInt32 n, UInt8 *buf);
// try to read up to n bytes; ret. number of bytes read, or -1 if error
typedef UInt8 (*JpegLibWriteFun)(void *clientData, UInt32 n, UInt8 *buf);
// try to write n bytes; ret. 1 if ok, 0 if error
typedef struct
{
UInt8 private[20];
} JpegLibData;
typedef struct
{
UInt8 private[20];
} JpegLibImageDescr;
typedef struct
{
UInt8 private[20];
} JpegLibDecodeOptions;
typedef struct
{
UInt8 private[20];
} JpegLibEncodeOptions;
Err JpegLibOpen(UInt16 refnum, UInt32 currentVersion)
SYS_TRAP(sysLibTrapOpen);
Err JpegLibClose(UInt16 refnum, UInt16 *usecount)
SYS_TRAP(sysLibTrapClose);
Err JpegLibRead(UInt16 refnum,
JpegLibData const *src, JpegLibDecodeOptions const *dopt,
UInt16 *width, UInt16 *height, UInt16 *nComp, void **data)
SYS_TRAP(sysLibTrapCustom);
Err JpegLibWrite(UInt16 refnum,
JpegLibImageDescr const *image, JpegLibEncodeOptions const *eopt,
JpegLibData *dest)
SYS_TRAP(sysLibTrapCustom + 1);
void JpegLibCreateImageDescrPtr(UInt16 refnum, JpegLibImageDescr *image,
UInt16 width, UInt16 height, UInt16 nComponents, UInt8 *pixels)
SYS_TRAP(sysLibTrapCustom + 2);
void JpegLibCreateDataPtr(UInt16 refnum, JpegLibData *src, MemPtr p, UInt32 size)
SYS_TRAP(sysLibTrapCustom + 3);
void JpegLibCreateDataHandle(UInt16 refnum, JpegLibData *src, MemHandle h)
SYS_TRAP(sysLibTrapCustom + 4);
void JpegLibCreateDataFileStreaming(UInt16 refnum, JpegLibData *src, FileHand fh)
SYS_TRAP(sysLibTrapCustom + 5);
void JpegLibCreateDataVFS(UInt16 refnum, JpegLibData *src, FileRef fileRef)
SYS_TRAP(sysLibTrapCustom + 6);
void JpegLibCreateDataReadFunction(UInt16 refnum, JpegLibData *src,
JpegLibReadFun read, void *clientData)
SYS_TRAP(sysLibTrapCustom + 7);
void JpegLibCreateDataWriteFunction(UInt16 refnum, JpegLibData *src,
JpegLibWriteFun write, void *clientData)
SYS_TRAP(sysLibTrapCustom + 8);
void JpegLibCreateEncOptions(UInt16 refnum, JpegLibEncodeOptions *eopt)
SYS_TRAP(sysLibTrapCustom + 9);
void JpegLibSetEncOptQuality(UInt16 refnum, JpegLibEncodeOptions *eopt, UInt16 quality)
SYS_TRAP(sysLibTrapCustom + 10);
void JpegLibSetEncOptProgressive(UInt16 refnum, JpegLibEncodeOptions *eopt, Boolean prog)
SYS_TRAP(sysLibTrapCustom + 11);
void JpegLibCreateDecOptions(UInt16 refnum, JpegLibDecodeOptions *dopt)
SYS_TRAP(sysLibTrapCustom + 12);
void JpegLibSetDecOptDestHandle(UInt16 refnum, JpegLibDecodeOptions *dopt)
SYS_TRAP(sysLibTrapCustom + 13);
void JpegLibSetDecOptDestBitmap(UInt16 refnum, JpegLibDecodeOptions *dopt)
SYS_TRAP(sysLibTrapCustom + 14);
void JpegLibSetDecOptForceBW(UInt16 refnum, JpegLibDecodeOptions *dopt)
SYS_TRAP(sysLibTrapCustom + 15);
void JpegLibSetDecOptScale(UInt16 refnum, JpegLibDecodeOptions *dopt, UInt16 scale)
SYS_TRAP(sysLibTrapCustom + 16);
Char const *JpegLibCopyright(UInt16 refnum)
SYS_TRAP(sysLibTrapCustom + 17);
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -