jpeg.pas在delphi的安装光盘里,安装后是没有的,如果你没有delphi的安装光盘去下一个graphicsex,那里面有个jpg.pas,也有ijg的obj文件但是没有源码了,jpeg的结构是很多行raw,ijg是个很通用的接口,据说IE用的也是这个,很多嵌入式都用这个的,比如数字电视的机顶盒,但是我非常奇怪你用delphi来搞嵌入式,呵呵,
付个例子吧,我以前的demo,用的是GraphicsEx里的jpg.pas
procedure TfrmMain.bbb(AFileName: String; AThumBmp: TBitmap; AWidth,
AHeight: Integer);
var cinfo:jpeg_decompress_struct;
jerr:jpeg_error_mgr;
FileStream:TFileStream;
DestScanLine: PByteArray;
num_scanlines:integer;
i:integer;
iByte:Byte;
begin
FileStream:=TFileStream.Create(AFileName,fmOpenRead or fmShareDenyNone) ;
jerr := jpeg_std_error;
cinfo.common.err := @jerr;
jpeg_CreateDecompress(@cinfo,JPEG_LIB_VERSION, sizeof(cinfo));
jpeg_stdio_src(@cinfo, FileStream);
if jpeg_read_header(@cinfo,true)<>1 then exit;
jpeg_start_decompress(@cinfo);
AThumBmp.Width:=CInfo.output_width;
AThumBmp.Height := CInfo.output_height;
AThumBmp.HandleType :=bmDib;
AThumBmp.PixelFormat := pf24bit;
Cinfo.output_scanline:=CInfo.output_height-10;
While(cinfo.output_scanline < cinfo.output_height) do begin
DestScanLine:=AThumBmp.ScanLine[Cinfo.output_scanline];
num_scanlines:=jpeg_read_scanlines(@cinfo, @DestScanLine, 1);
end;
jpeg_finish_decompress(@cinfo);
jpeg_destroy_decompress(@cinfo);
FileStream.Free;
end;