mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-02 01:59:29 +01:00
added package JPEGForLazarus
git-svn-id: trunk@5210 -
This commit is contained in:
parent
9d2bfc6100
commit
33dd6d0185
4
.gitattributes
vendored
4
.gitattributes
vendored
@ -82,6 +82,10 @@ components/interbase/tibdatabase.xpm -text svneol=native#image/x-xpixmap
|
||||
components/interbase/tibquery.ico -text svneol=unset#image/x-icon
|
||||
components/interbase/tibquery.xpm -text svneol=native#image/x-xpixmap
|
||||
components/interbase/tibtransaction.xpm -text svneol=native#image/x-xpixmap
|
||||
components/jpeg/jpegforlazarus.lpk svneol=native#text/pascal
|
||||
components/jpeg/jpegforlazarus.pas svneol=native#text/pascal
|
||||
components/jpeg/lazjpeg.pas svneol=native#text/pascal
|
||||
components/jpeg/readme.txt svneol=native#text/plain
|
||||
components/mpaslex/mpaslex.pp svneol=native#text/pascal
|
||||
components/mysql/mysqllaz.lpk svneol=native#text/pascal
|
||||
components/mysql/mysqllaz.pas svneol=native#text/pascal
|
||||
|
||||
43
components/jpeg/jpegforlazarus.lpk
Normal file
43
components/jpeg/jpegforlazarus.lpk
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<Package Version="2">
|
||||
<Name Value="JPEGForLazarus"/>
|
||||
<Author Value="Mattias Gaertner"/>
|
||||
<CompilerOptions>
|
||||
<SearchPaths>
|
||||
<UnitOutputDirectory Value="lib/"/>
|
||||
</SearchPaths>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Description Value="JPEG for Lazarus.
|
||||
|
||||
"/>
|
||||
<License Value="LGPL"/>
|
||||
<Version Major="1" Release="1"/>
|
||||
<Files Count="2">
|
||||
<Item1>
|
||||
<Filename Value="lazjpeg.pas"/>
|
||||
<UnitName Value="LazJPEG"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Filename Value="readme.txt"/>
|
||||
<Type Value="Text"/>
|
||||
</Item2>
|
||||
</Files>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<RequiredPkgs Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
<UnitPath Value="$(PkgOutDir)/"/>
|
||||
</UsageOptions>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
</PublishOptions>
|
||||
</Package>
|
||||
</CONFIG>
|
||||
21
components/jpeg/jpegforlazarus.pas
Normal file
21
components/jpeg/jpegforlazarus.pas
Normal file
@ -0,0 +1,21 @@
|
||||
{ This file was automatically created by Lazarus. Do not edit!
|
||||
This source is only used to compile and install
|
||||
the package JPEGForLazarus 1.0.1.
|
||||
}
|
||||
|
||||
unit JPEGForLazarus;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
LazJPEG, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterPackage('JPEGForLazarus', @Register)
|
||||
end.
|
||||
150
components/jpeg/lazjpeg.pas
Normal file
150
components/jpeg/lazjpeg.pas
Normal file
@ -0,0 +1,150 @@
|
||||
{ Copyright (C) 2003 Mattias Gaertner
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
}
|
||||
unit LazJPEG;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SysUtils, Classes, FPImage, IntfGraphics, Graphics, FPReadJPEG, FPWriteJPEG,
|
||||
ClipBrd;
|
||||
|
||||
type
|
||||
TJPEGQualityRange = TFPJPEGCompressionQuality;
|
||||
TJPEGPerformance = TJPEGReadPerformance;
|
||||
|
||||
TJPEGImage = class(TBitmap)
|
||||
private
|
||||
FPerformance: TJPEGPerformance;
|
||||
FProgressiveEncoding: boolean;
|
||||
FQuality: TJPEGQualityRange;
|
||||
protected
|
||||
procedure InitFPImageReader(ImgReader: TFPCustomImageReader); override;
|
||||
procedure FinalizeFPImageReader(ImgReader: TFPCustomImageReader); override;
|
||||
procedure InitFPImageWriter(ImgWriter: TFPCustomImageWriter); override;
|
||||
procedure ReadStream(Stream: TStream; Size: Longint); override;
|
||||
procedure WriteStream(Stream: TStream; WriteSize: Boolean); override;
|
||||
public
|
||||
constructor Create; override;
|
||||
function LazarusResourceTypeValid(const ResourceType: string): boolean; override;
|
||||
function GetDefaultMimeType: string; override;
|
||||
class function GetFPReaderForFileExt(
|
||||
const FileExtension: string): TFPCustomImageReaderClass; override;
|
||||
class function GetFPWriterForFileExt(
|
||||
const FileExtension: string): TFPCustomImageWriterClass; override;
|
||||
public
|
||||
property CompressionQuality: TJPEGQualityRange read FQuality write FQuality;
|
||||
property ProgressiveEncoding: boolean read FProgressiveEncoding;
|
||||
property Performance: TJPEGPerformance read FPerformance write FPerformance;
|
||||
end;
|
||||
|
||||
const
|
||||
DefaultJPEGMimeType = 'image/jpeg';
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
{ TJPEGImage }
|
||||
|
||||
procedure TJPEGImage.InitFPImageReader(ImgReader: TFPCustomImageReader);
|
||||
var
|
||||
JPEGReader: TFPReaderJPEG;
|
||||
begin
|
||||
if ImgReader is TFPReaderJPEG then begin
|
||||
JPEGReader:=TFPReaderJPEG(ImgReader);
|
||||
JPEGReader.Performance:=Performance;
|
||||
end;
|
||||
inherited InitFPImageReader(ImgReader);
|
||||
end;
|
||||
|
||||
procedure TJPEGImage.FinalizeFPImageReader(ImgReader: TFPCustomImageReader);
|
||||
var
|
||||
JPEGReader: TFPReaderJPEG;
|
||||
begin
|
||||
if ImgReader is TFPReaderJPEG then begin
|
||||
JPEGReader:=TFPReaderJPEG(ImgReader);
|
||||
FProgressiveEncoding:=JPEGReader.ProgressiveEncoding;
|
||||
end;
|
||||
inherited FinalizeFPImageReader(ImgReader);
|
||||
end;
|
||||
|
||||
procedure TJPEGImage.InitFPImageWriter(ImgWriter: TFPCustomImageWriter);
|
||||
var
|
||||
JPEGWriter: TFPWriterJPEG;
|
||||
begin
|
||||
if ImgWriter is TFPWriterJPEG then begin
|
||||
JPEGWriter:=TFPWriterJPEG(ImgWriter);
|
||||
if JPEGWriter<>nil then ;
|
||||
JPEGWriter.ProgressiveEncoding:=ProgressiveEncoding;
|
||||
JPEGWriter.CompressionQuality:=CompressionQuality;
|
||||
end;
|
||||
inherited InitFPImageWriter(ImgWriter);
|
||||
end;
|
||||
|
||||
function TJPEGImage.LazarusResourceTypeValid(const ResourceType: string
|
||||
): boolean;
|
||||
begin
|
||||
Result:=(ResourceType='JPG') or (ResourceType='JPEG');
|
||||
end;
|
||||
|
||||
function TJPEGImage.GetDefaultMimeType: string;
|
||||
begin
|
||||
Result:=DefaultJPEGMimeType;
|
||||
end;
|
||||
|
||||
function TJPEGImage.GetFPReaderForFileExt(const FileExtension: string
|
||||
): TFPCustomImageReaderClass;
|
||||
begin
|
||||
Result:=TFPReaderJPEG;
|
||||
end;
|
||||
|
||||
function TJPEGImage.GetFPWriterForFileExt(const FileExtension: string
|
||||
): TFPCustomImageWriterClass;
|
||||
begin
|
||||
Result:=TFPWriterJPEG;
|
||||
end;
|
||||
|
||||
procedure TJPEGImage.ReadStream(Stream: TStream; Size: Longint);
|
||||
begin
|
||||
ReadStreamWithFPImage(Stream,Size,TFPReaderJPEG);
|
||||
end;
|
||||
|
||||
procedure TJPEGImage.WriteStream(Stream: TStream; WriteSize: Boolean);
|
||||
begin
|
||||
WriteStreamWithFPImage(Stream,WriteSize,TFPWriterJPEG);
|
||||
end;
|
||||
|
||||
constructor TJPEGImage.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
FPerformance:=jpBestQuality;
|
||||
FProgressiveEncoding:=false;
|
||||
FQuality:=75;
|
||||
end;
|
||||
|
||||
initialization
|
||||
TPicture.RegisterFileFormat('jpg', 'JPEG Image File', TJPEGImage);
|
||||
TPicture.RegisterFileFormat('jpeg', 'JPEG Image File', TJPEGImage);
|
||||
TPicture.RegisterClipboardFormat(RegisterClipboardFormat(DefaultJPEGMimeType),
|
||||
TJPEGImage);
|
||||
|
||||
finalization
|
||||
TPicture.UnregisterGraphicClass(TJPEGImage);
|
||||
|
||||
end.
|
||||
|
||||
18
components/jpeg/readme.txt
Normal file
18
components/jpeg/readme.txt
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
The lazarus TJPEGImage is in lazjpeg.pas
|
||||
|
||||
It uses the pasjpeg and fpimage libs provided by FreePascal. See there for in
|
||||
more detailed jpeg handling.
|
||||
|
||||
|
||||
JPEG (pronounced "jay-peg") is a standardized familly of algorithms for
|
||||
compression of continous tone still images. Most JPEG processes are lossy,
|
||||
the output image is not exactly identical to the input image. However, on
|
||||
typical photographic images, very good compression levels can be obtained
|
||||
with no visible change, and remarkably high compression levels are possible
|
||||
if you can tolerate a low-quality image. The Independent JPEG Group (IJG) has
|
||||
created a free, portable C library for JPEG compression and decompression of
|
||||
JPEG images.
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user