mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 02:58:05 +02: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/pdfvrsemantico.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/svgvectorialwriter.pas svneol=native#text/plain
|
||||
components/fpweb/README.txt svneol=native#text/plain
|
||||
|
@ -40,7 +40,10 @@ type
|
||||
{ Printing formats }
|
||||
vfPostScript, vfEncapsulatedPostScript,
|
||||
{ GCode formats }
|
||||
vfGCodeAvisoCNCPrototipoV5, vfGCodeAvisoCNCPrototipoV6);
|
||||
vfGCodeAvisoCNCPrototipoV5, vfGCodeAvisoCNCPrototipoV6,
|
||||
{ Other formats }
|
||||
vfRAW
|
||||
);
|
||||
|
||||
const
|
||||
{ Default extensions }
|
||||
@ -53,6 +56,7 @@ const
|
||||
STR_AUTOCAD_EXCHANGE_EXTENSION = '.dxf';
|
||||
STR_ENCAPSULATEDPOSTSCRIPT_EXTENSION = '.eps';
|
||||
STR_LAS_EXTENSION = '.las';
|
||||
STR_RAW_EXTENSION = '.raw';
|
||||
|
||||
type
|
||||
TvCustomVectorialWriter = class;
|
||||
@ -1451,6 +1455,7 @@ begin
|
||||
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_LAS_EXTENSION) = 0 then Result := vfLAS
|
||||
else if AnsiCompareText(lExt, STR_RAW_EXTENSION) = 0 then Result := vfRAW
|
||||
else
|
||||
raise Exception.Create('TvVectorialDocument.GetFormatFromExtension: The extension (' + lExt + ') doesn''t match any supported formats.');
|
||||
end;
|
||||
|
@ -12,7 +12,7 @@
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Files Count="13">
|
||||
<Files Count="14">
|
||||
<Item1>
|
||||
<Filename Value="svgvectorialwriter.pas"/>
|
||||
<UnitName Value="svgvectorialwriter"/>
|
||||
@ -65,6 +65,10 @@
|
||||
<Filename Value="lasvectorialreader.pas"/>
|
||||
<UnitName Value="lasvectorialreader"/>
|
||||
</Item13>
|
||||
<Item14>
|
||||
<Filename Value="rawvectorialreadwrite.pas"/>
|
||||
<UnitName Value="rawvectorialreadwrite"/>
|
||||
</Item14>
|
||||
</Files>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<RequiredPkgs Count="2">
|
||||
@ -73,7 +77,7 @@
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="FCL"/>
|
||||
<MinVersion Major="1" Valid="True" Release="1"/>
|
||||
<MinVersion Major="1" Release="1" Valid="True"/>
|
||||
</Item2>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
|
@ -2,7 +2,7 @@
|
||||
This source is only used to compile and install the package.
|
||||
}
|
||||
|
||||
unit fpvectorialpkg;
|
||||
unit fpvectorialpkg;
|
||||
|
||||
interface
|
||||
|
||||
@ -10,14 +10,14 @@ uses
|
||||
svgvectorialwriter, fpvtocanvas, fpvectorial, fpvectbuildunit,
|
||||
dxfvectorialreader, cdrvectorialreader, avisozlib, avisocncgcodewriter,
|
||||
avisocncgcodereader, svgvectorialreader, epsvectorialreader, fpvutils,
|
||||
lasvectorialreader, LazarusPackageIntf;
|
||||
lasvectorialreader, rawvectorialreadwrite, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Register;
|
||||
procedure Register;
|
||||
begin
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterPackage('fpvectorialpkg', @Register);
|
||||
RegisterPackage('fpvectorialpkg', @Register);
|
||||
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