Jump to content

limelect

Members
  • Content Count

    937
  • Joined

  • Last visited

  • Days Won

    1

limelect last won the day on April 15 2022

limelect had the most liked content!

Community Reputation

53 Excellent

1 Follower

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. limelect

    PNG Chunks

    GR32_PortableNetworkGraphic.pas seems to be more extensive
  2. limelect

    PNG Chunks

    This is what I wrote
  3. limelect

    PNG Chunks

    While trying another project, I found that I do not understand PNG. As for that, I started writing a PNG TChunk investigating in Vcl.Imaging.pngimage and found out that it lacks many chunks. I used this pngnet-code-r26-trunk.zip c++ program as a reference and more. So my basic question is (if anyone knows) that Vcl.Imaging.pngimage has a full PNG specification, and if it lacks more chunks, does any other PAS PNG file have a full spec? Any recommendation?
  4. limelect

    Skia or else

    Let me elaborate I use the unit Png2Svg.Classes; from https://github.com/TextEditorPro/Png2Svg With PNG, it works great Obviously, with another format (jpg), for example, it does not altogh I load it into PNG The SVG result
  5. limelect

    Skia or else

    @timfrost Some components use DLL. As for Skia, this is one way to go. I have those above solutions, but they are not perfect for all graphics. This is why I look for help
  6. limelect

    Skia or else

    @timfrost We are talking Delphi, am I to convert C?
  7. limelect

    Skia or else

    I would like to make any picture format into SVG. I have ImgView321: TImgView32; as my bitmap I got to this point from a demo, and it works nicely procedure CreateSVG(const AOutputFileName: string; const AWidth, AHeight: Integer; const ADrawProc: TSkDrawProc); var LStream: TStream; LCanvas: ISkCanvas; begin LStream := TFileStream.Create(AOutputFileName, fmCreate); try LCanvas := TSkSVGCanvas.Make(RectF(0, 0, AWidth, AHeight), LStream, [TSkSVGCanvasFlag.ConvertTextToPaths]); ADrawProc(LCanvas);//, RectF(0, 0, AWidth, AHeight)); LCanvas := nil; finally LStream.Free; end; end; CreateSVG('G:\7\TestPict\output.svg', 256, 256, TSkDrawProc( procedure (const ACanvas: ISkCanvas; const ADest: TRectF) var LFont: ISkFont; LPaint: ISkPaint; begin LFont := TSkFont.Create(TSkTypeface.MakeFromFile('G:\7\TestPicts\2.tiff'), 23); LPaint := TSkPaint.Create; LPaint.Shader := TSkShader.MakeGradientLinear(PointF(0, 0), PointF(256, 145), $FFFF5F5F, $FF5B8DFE, TSkTileMode.Clamp); instead of this >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ACanvas.DrawSimpleText('"Each dream that you', 2, 25, LFont, LPaint); ACanvas.DrawSimpleText('leave behind is a part', 2, 55, LFont, LPaint); ACanvas.DrawSimpleText('of your future that will', 2, 85, LFont, LPaint); ACanvas.DrawSimpleText('no longer exist."', 2, 115, LFont, LPaint); ACanvas.DrawImage(); I like to make this <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Image here is ISkImage, but I have ImgView321. I tried ISkImage(ImgView321) or bitmap LFont := TSkFont.Create(TSkTypeface.MakeFromFile('G:\7\TestPicts\2.tiff'), 28); LPaint.Shader := nil; LPaint.Color := $FF5B8DFE; ACanvas.DrawSimpleText('(Steve Jobs)', 2, 150, LFont, LPaint);<< also delete this end)); end; So any suggestions on how to go about my need any picture to SVG And no DLL, plz PS<<<<<<<<<<<<<<<<<<<<< I tried and it works, but some pictures are bad because it is PNG to SVG procedure TForm1.Button3Click(Sender: TObject); const SVG_START_TAG = '<svg width="%d" height="%d" xmlns="http://www.w3.org/2000/svg">'; SVG_RECT_TAG = ' <rect x="%d" y="%d" width="%d" height="%d" fill="rgb(%d,%d,%d)" fill-opacity="%s" />'; SVG_END_TAG = '</svg>'; var FSVGStrings: TStringList; b: tbitmap; MyPng: TPngImage; LOptions: TPng2SvgOptions; LRects: TArray<TColorRect>; LFormatSettings: TFormatSettings; LRect: TColorRect; begin Include(LOptions, psSaveSvg); b := tbitmap.Create; b.Assign(ImgView321.Bitmap);<< some are jpg FOptions := LOptions; // loses transparency MyPng := TPngImage.Create; try // MyPng.LoadFromFile(FileSave); //Assign(b); MyPng.Assign(b); mypng.SaveToFile(JvDirectoryEdit2.Text + '\' + '55.png'); <<< hear png is ok but output of gpg bad FSVGStrings := TStringList.Create; // Convert; with FSVGStrings do begin Clear; Add(Format(SVG_START_TAG, [MyPng.Width, MyPng.Height])); LFormatSettings := TFormatSettings.Create; LFormatSettings.DecimalSeparator := '.'; LRects := MergePixels(MyPng); for LRect in LRects do Add(Format(SVG_RECT_TAG, [LRect.X, LRect.Y, LRect.Width, LRect.Height, LRect.RValue, LRect.GValue, LRect.BValue, FormatFloat('0.######', LRect.Alpha / 255, LFormatSettings)])); Add(SVG_END_TAG); FSVGStrings.SaveToFile(JvDirectoryEdit2.Text + '\' + Edit1.Text + '.svg'); // Form1.Memo1.Lines.Add( FSVGStrings.Text); end; finally MyPng.Free; FSVGStrings.Free; // LFormatSettings.Free; b.Free; end; end;
  8. limelect

    Bitmap and TWICImage

    Thanks, I thought so As you can see, I fixed it differently
  9. limelect

    Bitmap and TWICImage

    I fixed it by bringing b := TBitmap.Create; b.Assign(ImgView321.Bitmap); Send B to functions However, if I load b from a file, it does not work. (MyBitmap) I still wonder. Any explanation?
  10. limelect

    Bitmap and TWICImage

    Out of curiosity, I have 2 functions, one OK, the other not 2 exact function, the PNG returns a white picture, the TIFF works procedure BITMAPtoPNG2(MyBitmap: TBitmap; destinationfilename: string); var MyWIC: TWICImage; // preserves transparency begin // Assert( MyBitmap.PixelFormat := pf32bit; << it was 24 same result MyWIC := TWICImage.Create; try MyBitmap.AlphaFormat := afDefined; MyWIC.LoadFromFile(FileSave); <<<<<<<<<<<<<<<<<<<<<<I have to do that // MyWIC.Assign(MyBitmap); <<<<<<<<<<<<<<<<<<<<<<< this return white picture MyWIC.ImageFormat :=TWICImageFormat.wifPng ;//wifPng; if Form1.TestIfFileExist(destinationfilename) then MyWIC.SaveToFile(destinationfilename); finally MyWIC.Free; end; end; THIS IS OK procedure BITMAPtoTIFF(MyBitmap: TBitmap; destinationfilename: string); var MyWIC: TWICImage; begin MyWIC := TWICImage.Create; try MyWIC.Assign(MyBitmap); <<<<<<<<<<<<< This is OK MyWIC.ImageFormat := TWICImageFormat.wifTiff; if Form1.TestIfFileExist(destinationfilename) then MyWIC.SaveToFile(destinationfilename); finally MyWIC.Free; end; end;
  11. limelect

    Libreoffice integration struggles

    Tried the above source, and those lines did nothing LoadWriterDocumentFromBytes(BytesOf(TXTData)); // LoadWriterDocumentFromBytes(BytesOf(HTMLData),'HTML Document (Writer)'); // missing something may be // LoadWriterDocumentFromBytes(BytesOf(RTFData),'Rich Text'); // also LoadWriterDocumentFromBytes(BytesOf(CSVData), 'Text - txt - csv (StarCalc)', CSVFilterOption); // for some reason 'csv' is not enough
  12. limelect

    Libreoffice integration struggles

    This worked for me a while ago (* // query the XComponentLoader interface from the desktop XComponentLoader xComponentLoader = (XComponentLoader)UnoRuntime.queryInterface( XComponentLoader.class, desktop); // create empty array of PropertyValue structs, needed for loadComponentFromURL PropertyValue[] loadProps = new PropertyValue[0]; // load new calc file XComponent xSpreadsheetComponent = xComponentLoader.loadComponentFromURL( "private:factory/scalc", "_blank", 0, loadProps); // query its XSpreadsheetDocument interface, we want to use getSheets() XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument)UnoRuntime.queryInterface( XSpreadsheetDocument.class, xSpreadsheetComponent); // use getSheets to get spreadsheets container XSpreadsheets xSpreadsheets = xSpreadsheetDocument.getSheets(); //insert new sheet at position 0 and get it by name, then query its XSpreadsheet interface xSpreadsheets.insertNewByName("MySheet", (short)0); Object sheet = xSpreadsheets.getByName("MySheet"); XSpreadsheet xSpreadsheet = (XSpreadsheet)UnoRuntime.queryInterface( XSpreadsheet.class, sheet); // use XSpreadsheet interface to get the cell A1 at position 0,0 and enter 21 as value XCell xCell = xSpreadsheet.getCellByPosition(0, 0); xCell.setValue(21); // enter another value into the cell A2 at position 0,1 xCell = xSpreadsheet.getCellByPosition(0, 1); xCell.setValue(21); // sum up the two cells xCell = xSpreadsheet.getCellByPosition(0, 2); xCell.setFormula("=sum(A1:A2)"); // we want to access the cell property CellStyle, so query the cell's XPropertySet interface XPropertySet xCellProps = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, xCell); // assign the cell style "Result" to our formula, which is available out of the box xCellProps.setPropertyValue("CellStyle", "Result"); // we want to make our new sheet the current sheet, so we need to ask the model // for the controller: first query the XModel interface from our spreadsheet component XModel xSpreadsheetModel = (XModel)UnoRuntime.queryInterface( XModel.class, xSpreadsheetComponent); // then get the current controller from the model XController xSpreadsheetController = xSpreadsheetModel.getCurrentController(); // get the XSpreadsheetView interface from the controller, we want to call its method // setActiveSheet XSpreadsheetView xSpreadsheetView = (XSpreadsheetView)UnoRuntime.queryInterface( XSpreadsheetView.class, xSpreadsheetController); // make our newly inserted sheet the active sheet using setActiveSheet xSpreadsheetView.setActiveSheet(xSpreadsheet); } catch( com.sun.star.lang.DisposedException e ) { //works from Patch 1 xRemoteContext = null; throw e; } *) unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls; type TForm1 = class(TForm) Panel1: TPanel; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} uses System.Win.ComObj; procedure TForm1.Button1Click(Sender: TObject); var xSpreadsheet,sheet,xCell,xSpreadsheets ,args,objDocument,objDesktop,Excel, Book: OleVariant; RowNumber: integer; ColNumber: integer; const xlCellTypeLastCell = $0000000B; // ExcelXP begin //excel := CreateOleObject('Excel.Application'); excel := CreateOleObject('com.sun.star.ServiceManager'); objDesktop:=excel.createInstance('com.sun.star.frame.Desktop'); args := VarArrayCreate([0,1], varVariant); // objDocument:=objDesktop.loadComponentFromURL('private:factory/swriter','_blank', 0, args) ; //load empty documemt // objDocument:=objDesktop.loadComponentFromURL('private:factory/swriter','G:\Delphi Projects\engineertips\Excel Row and Column Count\world_gps_map_database.xls', 0, args) ; objDocument:=objDesktop.loadComponentFromURL('private:factory/scalc','_blank', 0, args) ; //load new excel xSpreadsheets:= objDocument.getSheets; xSpreadsheets.insertNewByName('MySheet', 0); sheet := xSpreadsheets.getByName('MySheet'); // xSpreadsheet := (XSpreadsheets).queryInterface( XSpreadsheet.class, sheet); //xCell := xSpreadsheets.getCellByPosition(0, 0); xCell := sheet.getCellByPosition(0, 0); xCell.setValue(21); xCell := sheet.getCellByPosition(1, 0); xCell.setValue(521); // RowNumber := Sheet.UsedRange.EntireRow.Count; (* excel.Workbooks.Open( 'G:\Delphi Projects\engineertips\Excel Row and Column Count\world_gps_map_database.xls' ); // Sheet := excel.ActiveWorkbook.Worksheets[SheetName]; Book := Excel.Workbooks.Open('G:\Delphi Projects\engineertips\Excel Row and Column Count\world_gps_map_database.xls', False, // ConfirmConversions True ); // ReadOnly Sheet := Book.Worksheets[1]; //RowNumber := Sheet.UsedRange.EntireRow.Count; // May be wrong! //ColNumber := Sheet.UsedRange.EntireColumn.Count; // May be wrong! RowNumber := Sheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row; ColNumber := Sheet.UsedRange.SpecialCells(xlCellTypeLastCell).Column; *) end; end.
  13. @Gabor64738 No, I think another way First, throw away all the files except the DPR fmx res and pas. Now load the DPR. Usually, this will be OK. If not, there is another option. Edit the DPR so All the paths will only be the file names. With that said, you have here are all the project files. And lastly, if this did not help, make a new project (name the new main to the old main) and also the project name to the old one. Change (copy) pas and fmx of the old main to the new one, then add all other pas files to the project. Doen.
  14. limelect

    D12 sdk and Android

    @Dave NottageWell, you might be right, but as a professional using Pascal even before Delphi, I do not have the strength to use failing products. For Android, I will stick with Android Studio even though Delphi is better in that area and wait for a new version Maybe I will give it one more shot
  15. limelect

    D12 sdk and Android

    I will wait for Delphi 13, maybe it will be better
×