mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-07 08:29:45 +01:00
fpvectorial: Adds a raw image reader
git-svn-id: trunk@36417 -
This commit is contained in:
parent
59c2fa486c
commit
ea3f4edab2
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1024,6 +1024,7 @@ components/fpvectorial/pdfvectorialreader.pas svneol=native#text/plain
|
|||||||
components/fpvectorial/pdfvrlexico.pas svneol=native#text/plain
|
components/fpvectorial/pdfvrlexico.pas svneol=native#text/plain
|
||||||
components/fpvectorial/pdfvrsemantico.pas svneol=native#text/plain
|
components/fpvectorial/pdfvrsemantico.pas svneol=native#text/plain
|
||||||
components/fpvectorial/pdfvrsintatico.pas svneol=native#text/plain
|
components/fpvectorial/pdfvrsintatico.pas svneol=native#text/plain
|
||||||
|
components/fpvectorial/rawvectorialreadwrite.pas svneol=native#text/plain
|
||||||
components/fpvectorial/svgvectorialreader.pas svneol=native#text/plain
|
components/fpvectorial/svgvectorialreader.pas svneol=native#text/plain
|
||||||
components/fpvectorial/svgvectorialwriter.pas svneol=native#text/plain
|
components/fpvectorial/svgvectorialwriter.pas svneol=native#text/plain
|
||||||
components/fpweb/README.txt svneol=native#text/plain
|
components/fpweb/README.txt svneol=native#text/plain
|
||||||
|
|||||||
@ -40,7 +40,10 @@ type
|
|||||||
{ Printing formats }
|
{ Printing formats }
|
||||||
vfPostScript, vfEncapsulatedPostScript,
|
vfPostScript, vfEncapsulatedPostScript,
|
||||||
{ GCode formats }
|
{ GCode formats }
|
||||||
vfGCodeAvisoCNCPrototipoV5, vfGCodeAvisoCNCPrototipoV6);
|
vfGCodeAvisoCNCPrototipoV5, vfGCodeAvisoCNCPrototipoV6,
|
||||||
|
{ Other formats }
|
||||||
|
vfRAW
|
||||||
|
);
|
||||||
|
|
||||||
const
|
const
|
||||||
{ Default extensions }
|
{ Default extensions }
|
||||||
@ -53,6 +56,7 @@ const
|
|||||||
STR_AUTOCAD_EXCHANGE_EXTENSION = '.dxf';
|
STR_AUTOCAD_EXCHANGE_EXTENSION = '.dxf';
|
||||||
STR_ENCAPSULATEDPOSTSCRIPT_EXTENSION = '.eps';
|
STR_ENCAPSULATEDPOSTSCRIPT_EXTENSION = '.eps';
|
||||||
STR_LAS_EXTENSION = '.las';
|
STR_LAS_EXTENSION = '.las';
|
||||||
|
STR_RAW_EXTENSION = '.raw';
|
||||||
|
|
||||||
type
|
type
|
||||||
TvCustomVectorialWriter = class;
|
TvCustomVectorialWriter = class;
|
||||||
@ -1451,6 +1455,7 @@ begin
|
|||||||
else if AnsiCompareText(lExt, STR_AUTOCAD_EXCHANGE_EXTENSION) = 0 then Result := vfDXF
|
else if AnsiCompareText(lExt, STR_AUTOCAD_EXCHANGE_EXTENSION) = 0 then Result := vfDXF
|
||||||
else if AnsiCompareText(lExt, STR_ENCAPSULATEDPOSTSCRIPT_EXTENSION) = 0 then Result := vfEncapsulatedPostScript
|
else if AnsiCompareText(lExt, STR_ENCAPSULATEDPOSTSCRIPT_EXTENSION) = 0 then Result := vfEncapsulatedPostScript
|
||||||
else if AnsiCompareText(lExt, STR_LAS_EXTENSION) = 0 then Result := vfLAS
|
else if AnsiCompareText(lExt, STR_LAS_EXTENSION) = 0 then Result := vfLAS
|
||||||
|
else if AnsiCompareText(lExt, STR_RAW_EXTENSION) = 0 then Result := vfRAW
|
||||||
else
|
else
|
||||||
raise Exception.Create('TvVectorialDocument.GetFormatFromExtension: The extension (' + lExt + ') doesn''t match any supported formats.');
|
raise Exception.Create('TvVectorialDocument.GetFormatFromExtension: The extension (' + lExt + ') doesn''t match any supported formats.');
|
||||||
end;
|
end;
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
<CompilerPath Value="$(CompPath)"/>
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
</Other>
|
</Other>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Files Count="13">
|
<Files Count="14">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="svgvectorialwriter.pas"/>
|
<Filename Value="svgvectorialwriter.pas"/>
|
||||||
<UnitName Value="svgvectorialwriter"/>
|
<UnitName Value="svgvectorialwriter"/>
|
||||||
@ -65,6 +65,10 @@
|
|||||||
<Filename Value="lasvectorialreader.pas"/>
|
<Filename Value="lasvectorialreader.pas"/>
|
||||||
<UnitName Value="lasvectorialreader"/>
|
<UnitName Value="lasvectorialreader"/>
|
||||||
</Item13>
|
</Item13>
|
||||||
|
<Item14>
|
||||||
|
<Filename Value="rawvectorialreadwrite.pas"/>
|
||||||
|
<UnitName Value="rawvectorialreadwrite"/>
|
||||||
|
</Item14>
|
||||||
</Files>
|
</Files>
|
||||||
<Type Value="RunAndDesignTime"/>
|
<Type Value="RunAndDesignTime"/>
|
||||||
<RequiredPkgs Count="2">
|
<RequiredPkgs Count="2">
|
||||||
@ -73,7 +77,7 @@
|
|||||||
</Item1>
|
</Item1>
|
||||||
<Item2>
|
<Item2>
|
||||||
<PackageName Value="FCL"/>
|
<PackageName Value="FCL"/>
|
||||||
<MinVersion Major="1" Valid="True" Release="1"/>
|
<MinVersion Major="1" Release="1" Valid="True"/>
|
||||||
</Item2>
|
</Item2>
|
||||||
</RequiredPkgs>
|
</RequiredPkgs>
|
||||||
<UsageOptions>
|
<UsageOptions>
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
This source is only used to compile and install the package.
|
This source is only used to compile and install the package.
|
||||||
}
|
}
|
||||||
|
|
||||||
unit fpvectorialpkg;
|
unit fpvectorialpkg;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
@ -10,14 +10,14 @@ uses
|
|||||||
svgvectorialwriter, fpvtocanvas, fpvectorial, fpvectbuildunit,
|
svgvectorialwriter, fpvtocanvas, fpvectorial, fpvectbuildunit,
|
||||||
dxfvectorialreader, cdrvectorialreader, avisozlib, avisocncgcodewriter,
|
dxfvectorialreader, cdrvectorialreader, avisozlib, avisocncgcodewriter,
|
||||||
avisocncgcodereader, svgvectorialreader, epsvectorialreader, fpvutils,
|
avisocncgcodereader, svgvectorialreader, epsvectorialreader, fpvutils,
|
||||||
lasvectorialreader, LazarusPackageIntf;
|
lasvectorialreader, rawvectorialreadwrite, LazarusPackageIntf;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
RegisterPackage('fpvectorialpkg', @Register);
|
RegisterPackage('fpvectorialpkg', @Register);
|
||||||
end.
|
end.
|
||||||
|
|||||||
80
components/fpvectorial/rawvectorialreadwrite.pas
Normal file
80
components/fpvectorial/rawvectorialreadwrite.pas
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
{
|
||||||
|
A very simple raw image format
|
||||||
|
|
||||||
|
AUTHORS: Felipe Monteiro de Carvalho
|
||||||
|
|
||||||
|
License: The same modified LGPL as the Free Pascal RTL
|
||||||
|
See the file COPYING.modifiedLGPL for more details
|
||||||
|
}
|
||||||
|
unit rawvectorialreadwrite;
|
||||||
|
|
||||||
|
{$ifdef fpc}
|
||||||
|
{$mode delphi}
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, dateutils,
|
||||||
|
fpcanvas, fpimage,
|
||||||
|
intfgraphics, graphtype,
|
||||||
|
//avisozlib,
|
||||||
|
fpvectorial;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TvRAWVectorialReader }
|
||||||
|
|
||||||
|
TvRAWVectorialReader = class(TvCustomVectorialReader)
|
||||||
|
public
|
||||||
|
{ General reading methods }
|
||||||
|
procedure ReadFromStream(AStream: TStream; AData: TvVectorialDocument); override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
RAW_IMAGE_WIDTH, RAW_IMAGE_HEIGHT: Integer;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{ TvRAWVectorialReader }
|
||||||
|
|
||||||
|
procedure TvRAWVectorialReader.ReadFromStream(AStream: TStream;
|
||||||
|
AData: TvVectorialDocument);
|
||||||
|
var
|
||||||
|
lPage: TvVectorialPage;
|
||||||
|
lRasterImage: TvRasterImage;
|
||||||
|
AImage: TLazIntfImage;
|
||||||
|
lRawImage: TRawImage;
|
||||||
|
x, y: Integer;
|
||||||
|
lColor: TFPColor;
|
||||||
|
begin
|
||||||
|
// create a TLazIntfImage with 32 bits per pixel, alpha 8bit, red 8 bit, green 8bit, blue 8bit,
|
||||||
|
// Bits In Order: bit 0 is pixel 0, Top To Bottom: line 0 is top
|
||||||
|
lRawImage.Init;
|
||||||
|
lRawImage.Description.Init_BPP24_R8G8B8_BIO_TTB(RAW_IMAGE_WIDTH, RAW_IMAGE_HEIGHT);
|
||||||
|
lRawImage.CreateData(True);
|
||||||
|
AImage := TLazIntfImage.Create(0,0);
|
||||||
|
|
||||||
|
AImage.SetRawImage(lRawImage);
|
||||||
|
|
||||||
|
for x := 0 to RAW_IMAGE_WIDTH - 1 do
|
||||||
|
for y := 0 to RAW_IMAGE_HEIGHT - 1 do
|
||||||
|
begin
|
||||||
|
lColor.Red := AStream.ReadByte() * $FF;
|
||||||
|
AImage.Colors[x, y] := lColor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
lPage := AData.AddPage();
|
||||||
|
lRasterImage := TvRasterImage.Create;
|
||||||
|
lRasterImage.RasterImage := AImage;
|
||||||
|
lPage.AddEntity(lRasterImage);
|
||||||
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
|
||||||
|
RAW_IMAGE_WIDTH := 1024;
|
||||||
|
RAW_IMAGE_HEIGHT := 1024;
|
||||||
|
RegisterVectorialReader(TvRAWVectorialReader, vfRAW);
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user