diff --git a/.gitattributes b/.gitattributes index 034e8c299a..4daada4716 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/components/fpvectorial/fpvectorial.pas b/components/fpvectorial/fpvectorial.pas index 3910135a22..488557cd84 100644 --- a/components/fpvectorial/fpvectorial.pas +++ b/components/fpvectorial/fpvectorial.pas @@ -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; diff --git a/components/fpvectorial/fpvectorialpkg.lpk b/components/fpvectorial/fpvectorialpkg.lpk index d1d6427a55..5b1565af2b 100644 --- a/components/fpvectorial/fpvectorialpkg.lpk +++ b/components/fpvectorial/fpvectorialpkg.lpk @@ -12,7 +12,7 @@ - + @@ -65,6 +65,10 @@ + + + + @@ -73,7 +77,7 @@ - + diff --git a/components/fpvectorial/fpvectorialpkg.pas b/components/fpvectorial/fpvectorialpkg.pas index d22683747d..4bcace8ff6 100644 --- a/components/fpvectorial/fpvectorialpkg.pas +++ b/components/fpvectorial/fpvectorialpkg.pas @@ -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. diff --git a/components/fpvectorial/rawvectorialreadwrite.pas b/components/fpvectorial/rawvectorialreadwrite.pas new file mode 100644 index 0000000000..d4af2f4c57 --- /dev/null +++ b/components/fpvectorial/rawvectorialreadwrite.pas @@ -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. +