📄 libjpegdelphi.pas
字号:
CConvert: PRJpegColorConverter;
Downsample: PRJpegDownsampler;
FDct: PRJpegForwardDct;
Entropy: PRJpegEntropyEncoder;
ScriptSpace: PRJpegScanInfo; { workspace for jpeg_simple_progression }
ScriptSpaceSize: Integer;
end;
RJpegDecompressStruct = record
{ Fields shared with jpeg_compress_struct }
Err: PRJpegErrorMgr; { Error handler module }
Mem: PRJpegMemoryMgr; { Memory manager module }
Progress: PRJpegProgressMgr; { Progress monitor, or NULL if none }
ClientData: Pointer; { Available for use by application }
IsDecompressor: Boolean; { So common code can tell which is which }
GlobalState: Integer; { For checking call sequence validity }
{ Source of compressed data }
Src: PRJpegSourceMgr;
{ Basic description of image --- filled in by jpeg_read_header(). }
{ Application may inspect these values to decide how to process image. }
ImageWidth: Cardinal; { nominal image width (from SOF marker) }
ImageHeight: Cardinal; { nominal image height }
NumComponents: Integer; { # of color components in JPEG image }
JpegColorSpace: Integer; { colorspace of JPEG image }
{ Decompression processing parameters --- these fields must be set before calling jpeg_start_decompress(). Note that
jpeg_read_header() initializes them to default values. }
OutColorSpace: Integer; { colorspace for output }
ScaleNum,ScaleDenom: Cardinal; { fraction by which to scale image }
OutputGamme: Double; { image gamma wanted in output }
BufferedImage: Boolean; { TRUE=multiple output passes }
RawDataOut: Boolean; { TRUE=downsampled data wanted }
DctMethod: Integer; { IDCT algorithm selector }
DoFancyUpsampling: Boolean; { TRUE=apply fancy upsampling }
DoBlockSmoothing: Boolean; { TRUE=apply interblock smoothing }
QuantizeColors: Boolean; { TRUE=colormapped output wanted }
{ the following are ignored if not quantize_colors: }
DitherMode: Integer; { type of color dithering to use }
TwoPassQuantize: Boolean; { TRUE=use two-pass color quantization }
DesiredNumberOfColors: Integer;{ max # colors to use in created colormap }
{ these are significant only in buffered-image mode: }
Enable1PassQuant: Boolean; { enable future use of 1-pass quantizer }
EnableExternalQuant: Boolean; { enable future use of external colormap }
Enable2PassQuant: Boolean; { enable future use of 2-pass quantizer }
{ Description of actual output image that will be returned to application. These fields are computed by jpeg_start_decompress().
You can also use jpeg_calc_output_dimensions() to determine these values in advance of calling jpeg_start_decompress(). }
OutputWidth: Cardinal; { scaled image width }
OutputHeight: Cardinal; { scaled image height }
OutColorComponents: Integer; { # of color components in out_color_space }
OutputComponents: Integer; { # of color components returned }
{ output_components is 1 (a colormap index) when quantizing colors; otherwise it equals out_color_components. }
RecOutbufHeight: Integer; { min recommended height of scanline buffer }
{ If the buffer passed to jpeg_read_scanlines() is less than this many rows high, space and time will be wasted due to unnecessary
data copying. Usually rec_outbuf_height will be 1 or 2, at most 4. }
{ When quantizing colors, the output colormap is described by these fields. The application can supply a colormap by setting
colormap non-NULL before calling jpeg_start_decompress; otherwise a colormap is created during jpeg_start_decompress or
jpeg_start_output. The map has out_color_components rows and actual_number_of_colors columns. }
ActualNumberOfColors: Integer; { number of entries in use }
Colormap: Pointer; { The color map as a 2-D pixel array }
{ State variables: these variables indicate the progress of decompression. The application may examine these but must not modify
them. }
{ Row index of next scanline to be read from jpeg_read_scanlines(). Application may use this to control its processing loop, e.g.,
"while (output_scanline < output_height)". }
OutputScanline: Cardinal; { 0 .. output_height-1 }
{ Current input scan number and number of iMCU rows completed in scan. These indicate the progress of the decompressor input side. }
InputScanNumber: Integer; { Number of SOS markers seen so far }
InputIMcuRow: Cardinal; { Number of iMCU rows completed }
{ The "output scan number" is the notional scan being displayed by the output side. The decompressor will not allow output
scan/row number to get ahead of input scan/row, but it can fall arbitrarily far behind. }
OutputScanNumber: Integer; { Nominal scan number being displayed }
OutputIMcuRow: Cardinal; { Number of iMCU rows read }
{ Current progression status. coef_bits[c][i] indicates the precision with which component c's DCT coefficient i (in zigzag order)
is known. It is -1 when no data has yet been received, otherwise it is the point transform (shift) value for the most recent scan
of the coefficient (thus, 0 at completion of the progression). This pointer is NULL when reading a non-progressive file. }
CoefBits: Pointer; { -1 or current Al value for each coef }
{ Internal JPEG parameters --- the application usually need not look at these fields. Note that the decompressor output side may
not use any parameters that can change between scans. }
{ Quantization and Huffman tables are carried forward across input datastreams when processing abbreviated JPEG datastreams. }
QuantTblPtrs: array[0..NUM_QUANT_TBLS-1] of Pointer;
{ ptrs to coefficient quantization tables, or NULL if not defined }
DcHuffTblPtrs: array[0..NUM_HUFF_TBLS-1] of Pointer;
AcHuffTblPtrs: array[0..NUM_HUFF_TBLS-1] of Pointer;
{ ptrs to Huffman coding tables, or NULL if not defined }
{ These parameters are never carried across datastreams, since they are given in SOF/SOS markers or defined to be reset by SOI. }
DataPrecision: Integer; { bits of precision in image data }
CompInfo: PRJpegComponentInfo; { comp_info[i] describes component that appears i'th in SOF }
ProgressiveMode: Boolean; { TRUE if SOFn specifies progressive mode }
ArithCode: Boolean; { TRUE=arithmetic coding, FALSE=Huffman }
ArithDcL: array[0..NUM_ARITH_TBLS-1] of Byte; { L values for DC arith-coding tables }
ArithDcY: array[0..NUM_ARITH_TBLS-1] of Byte; { U values for DC arith-coding tables }
ArithAcK: array[0..NUM_ARITH_TBLS-1] of Byte; { Kx values for AC arith-coding tables }
RestartInterval: Cardinal; { MCUs per restart interval, or 0 for no restart }
{ These fields record data obtained from optional markers recognized by the JPEG library. }
SawJfifMarker: Boolean; { TRUE iff a JFIF APP0 marker was found }
{ Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: }
JfifMajorVersion: Byte; { JFIF version number }
JfifMinorVersion: Byte; { JFIF code for pixel size units }
XDensity: Word; { Horizontal pixel density }
YDensity: Word; { Vertical pixel density }
SawAdobeMarker: Boolean; { TRUE iff an Adobe APP14 marker was found }
AdobeTransform: Byte; { Color transform code from Adobe marker }
Ccir601Sampling: Boolean; { TRUE=first samples are cosited }
{ Aside from the specific data retained from APPn markers known to the library, the uninterpreted contents of any or all APPn and
COM markers can be saved in a list for examination by the application. }
MarkerList: PRJpegSavedMarker; { Head of list of saved markers }
{ Remaining fields are known throughout decompressor, but generally should not be touched by a surrounding application. }
{ These fields are computed during decompression startup }
MaxHSampFactor: Integer; { largest h_samp_factor }
MaxVSampFactor: Integer; { largest v_samp_factor }
MinDctScaledSize: Integer; { smallest DCT_scaled_size of any component }
TotalIMcuRows: Cardinal; { # of iMCU rows in image }
{ The coefficient controller's input and output progress is measured in units of "iMCU" (interleaved MCU) rows. These are the same
as MCU rows in fully interleaved JPEG scans, but are used whether the scan is interleaved or not. We define an iMCU row as
v_samp_factor DCT block rows of each component. Therefore, the IDCT output contains v_samp_factor*DCT_scaled_size sample rows
of a component per iMCU row. }
SampleRangeLimit: Pointer; { table for fast range-limiting }
{ These fields are valid during any one scan. They describe the components and MCUs actually appearing in the scan. Note that the
decompressor output side must not use these fields. }
CompsInScan: Integer; { # of JPEG components in this scan }
CurCompInfo: array[0..MAX_COMPS_IN_SCAN-1] of PRJpegComponentInfo;
{ *cur_comp_info[i] describes component that appears i'th in SOS }
McusPerRow: Cardinal; { # of MCUs across the image }
McuRowsInScan: Cardinal; { # of MCU rows in the image }
BlocksInMcu: Integer; { # of DCT blocks per MCU }
McuMembership: array[0..D_MAX_BLOCKS_IN_MCU-1] of Integer;
{ MCU_membership[i] is index in cur_comp_info of component owning i'th block in an MCU }
Ss,Se,Ah,Al: Integer; { progressive JPEG parameters for scan }
{ This field is shared between entropy decoder and marker parser. It is either zero or the code of a JPEG marker that has been read
from the data source, but has not yet been processed. }
UnreadMarker: Integer;
{ Links to decompression subobjects (methods, private variables of modules) }
Master: PRJpegDecompMaster;
Main: PRJpegDMainController;
Coef: PRJpegDCoefController;
Post: PRJpegDPosController;
InputCtl: PRJpegInputController;
Marker: PRJpegMarkerReader;
Entropy: PRJpegEntropyDecoder;
IDct: PRJpegInverseDct;
Upsample: PRJpegUpsampler;
CConvert: PRJpegColorDeconverter;
CQuantize: PRJpegColorQuantizer;
end;
procedure jpeg_create_compress(cinfo: PRJpegCompressStruct); cdecl;
procedure jpeg_CreateCompress(cinfo: PRJpegCompressStruct; version: Integer; structsize: Cardinal); cdecl; external;
procedure jpeg_create_decompress(cinfo: PRJpegDecompressStruct); cdecl;
procedure jpeg_CreateDecompress(cinfo: PRJpegDecompressStruct; version: Integer; structsize: Cardinal); cdecl; external;
procedure jpeg_abort(cinfo: PRJpegCommonStruct); cdecl; external;
procedure jpeg_set_defaults(cinfo: PRJpegCompressStruct); cdecl; external;
procedure jpeg_set_colorspace(cinfo: PRJpegCompressStruct; colorspace: Integer); cdecl; external;
procedure jpeg_set_quality(cinfo: PRJpegCompressStruct; quality: Integer; force_baseline: Byte); cdecl; external;
procedure jpeg_suppress_tables(cinfo: PRJpegCompressStruct; suppress: Byte); cdecl; external;
procedure jpeg_start_compress(cinfo: PRJpegCompressStruct; write_all_tables: Byte); cdecl; external;
function jpeg_write_scanlines(cinfo: PRJpegCompressStruct; scanlines: PPointer; num_lines: Cardinal): Cardinal; cdecl; external;
function jpeg_write_raw_data(cinfo: PRJpegCompressStruct; data: Pointer; num_lines: Cardinal): Cardinal; cdecl; external;
procedure jpeg_finish_compress(cinfo: PRJpegCompressStruct); cdecl; external;
procedure jpeg_write_tables(cinfo: PRJpegCompressStruct); cdecl; external;
function jpeg_read_header(cinfo: PRJpegDecompressStruct; require_image: Boolean): Integer; cdecl; external;
function jpeg_start_decompress(cinfo: PRJpegDecompressStruct): Byte; cdecl; external;
function jpeg_read_scanlines(cinfo: PRJpegDecompressStruct; scanlines: Pointer; max_lines: Cardinal): Cardinal; cdecl; external;
function jpeg_read_raw_data(cinfo: PRJpegDecompressStruct; data: Pointer; max_lines: Cardinal): Cardinal; cdecl; external;
function jpeg_finish_decompress(cinfo: PRJpegDecompressStruct): Byte; cdecl; external;
procedure jpeg_destroy(cinfo: PRJpegCommonStruct); cdecl; external;
function jpeg_std_error(err: PRJpegErrorMgr): Pointer; cdecl; external;
function jpeg_resync_to_restart(cinfo: PRJpegDecompressStruct; desired: Integer): Byte; cdecl; external;
implementation
uses
LibDelphi;
{jpeg}
procedure jpeg_error_exit_raise; cdecl;
begin
raise Exception.Create('LibJpeg error_exit');
end;
procedure jpeg_create_compress(cinfo: PRJpegCompressStruct); cdecl;
begin
jpeg_CreateCompress(cinfo,JPEG_LIB_VERSION,SizeOf(RJpegCompressStruct));
end;
procedure jpeg_create_decompress(cinfo: PRJpegDecompressStruct); cdecl;
begin
jpeg_CreateDecompress(cinfo,JPEG_LIB_VERSION,SizeOf(RJpegDecompressStruct));
end;
{jmemnobs}
function jpeg_get_small(cinfo: PRJpegCommonStruct; sizeofobject: Cardinal): Pointer; cdecl; external;
function jpeg_get_large(cinfo: PRJpegCommonStruct; sizeofobject: Cardinal): Pointer; cdecl; external;
function jpeg_mem_available(cinfo: PRJpegCommonStruct; min_bytes_needed: Integer; max_bytes_needed: Integer; already_allocated: Integer): Integer; cdecl; external;
procedure jpeg_open_backing_store(cinfo: PRJpegCommonStruct; info: Pointer; total_bytes_needed: Integer); cdecl; external;
procedure jpeg_free_large(cinfo: PRJpegCommonStruct; objectt: Pointer; sizeofobject: Cardinal); cdecl; external;
procedure jpeg_free_small(cinfo: PRJpegCommonStruct; objectt: Pointer; sizeofobject: Cardinal); cdecl; external;
procedure jpeg_mem_term(cinfo: PRJpegCommonStruct); cdecl; external;
function jpeg_mem_init(cinfo: PRJpegCommonStruct): Integer; cdecl; external;
{$IFDEF LIBJPEG_DEBUG}
{$L LibJpegDelphi\debug\jmemnobs.obj}
{$ELSE}
{$L LibJpegDelphi\release\jmemnobs.obj}
{$ENDIF}
{jmemmgr}
procedure jinit_memory_mgr(cinfo: PRJpegCommonStruct); cdecl; external;
{$IFDEF LIBJPEG_DEBUG}
{$L LibJpegDelphi\debug\jmemmgr.obj}
{$ELSE}
{$L LibJpegDelphi\release\jmemmgr.obj}
{$ENDIF}
{jcomapi}
function jpeg_alloc_huff_table(cinfo: PRJpegCommonStruct): Pointer; cdecl; external;
function jpeg_alloc_quant_table(cinfo: PRJpegCommonStruct): Pointer; cdecl; external;
{$IFDEF LIBJPEG_DEBUG}
{$L LibJpegDelphi\debug\jcomapi.obj}
{$ELSE}
{$L LibJpegDelphi\release\jcomapi.obj}
{$ENDIF}
{jerror}
{$IFDEF LIBJPEG_DEBUG}
{$L LibJpegDelphi\debug\jerror.obj}
{$ELSE}
{$L LibJpegDelphi\release\jerror.obj}
{$ENDIF}
{jcapimin}
{$IFDEF LIBJPEG_DEBUG}
{$L LibJpegDelphi\debug\jcapimin.obj}
{$ELSE}
{$L LibJpegDelphi\release\jcapimin.obj}
{$ENDIF}
{jcmarker}
{$IFDEF LIBJPEG_DEBUG}
{$L LibJpegDelphi\debug\jcmarker.obj}
{$ELSE}
{$L LibJpegDelphi\release\jcmarker.obj}
{$ENDIF}
{jutils}
function jdiv_round_up(a: Integer; b: Integer): Integer; cdecl; external;
procedure jcopy_sample_rows(input_array: Pointer; source_row: Integer; output_array: Pointer; dest_row: Integer; num_rows: Integer;
num_cols: Cardinal); cdecl; external;
function jround_up(a: Integer; b: Integer): Integer; cdecl; external;
procedure jcopy_block_row(input_row: Pointer; output_row: Pointer; num_blocks: Cardinal); cdecl; external;
{$IFDEF LIBJPEG_DEBUG}
{$L LibJpegDelphi\debug\jutils.obj}
{$ELSE}
{$L LibJpegDelphi\release\jutils.obj}
{$ENDIF}
{jdapimin}
{$IFDEF LIBJPEG_DEBUG}
{$L LibJpegDelphi\debug\jdapimin.obj}
{$ELSE}
{$L LibJpegDelphi\release\jdapimin.obj}
{$ENDIF}
{jdmarker}
{$IFDEF LIBJPEG_DEBUG}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -