

limelect
Members-
Content Count
937 -
Joined
-
Last visited
-
Days Won
1
Everything posted by limelect
-
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?
-
GR32_PortableNetworkGraphic.pas seems to be more extensive
-
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
-
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;
-
@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
-
@timfrost We are talking Delphi, am I to convert C?
-
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;
-
Thanks, I thought so As you can see, I fixed it differently
-
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?
-
Libreoffice integration struggles
limelect replied to Pierre le Riche's topic in RTL and Delphi Object Pascal
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 -
Libreoffice integration struggles
limelect replied to Pierre le Riche's topic in RTL and Delphi Object Pascal
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. -
Broken Project Path References due to Misused “Save As” in Delphi (RAD Studio)
limelect replied to Badnaf's topic in FMX
@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. -
No SDK in the directory after installation of D12 C:\Users\Public\Documents\Embarcadero\Studio\23.0\CatalogRepository\AndroidSDK-2525-23.0.51961.7529 On my d10.2.3, there are a few exe files, including AVD Manager.exe C:\Users\Public\Documents\Embarcadero\Studio\19.0\CatalogRepository\AndroidSDK-2433_19.0.27659.1188 SDK base path I did choose Android during the installation Can I copy my d10 to my d12 ? or what On compiling, I get initialization of VM error D12 community edition P.S I have seen this
-
@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
-
I will wait for Delphi 13, maybe it will be better
-
The error saise Cannot locate sdk api level in this path..... I geuss it is not 32 bit
-
Yes, I started by checking the Java path, but on the 32 it does not allow me to change Furthermore, I tried to compile to 64, but it wants to update. I say ye,s it fails with no reason
-
@Dave Nottage It is a mess; most directories are bad On Java 32-bit, it does not allow me to change it Maybe because I put both 32 and 64 as the same directory? The adb.exe does not exist and so on Up to today, I have bought all the Delphi. Should I buy now? Is this a Delphi joke
-
Cannot deploy the application All Java should be in c:\bin, why? Ok, I put Java in bin Now it need c:\bin\ client\jvm.dll So I made this directory with jvm.dll I have jvm.dll in the server directory Lastly, I have this error during the initialization of VM Obviously, D12 did not initialize its Java during installation Any help?
-
@Cristian Peța Sdk and Java it is not the same problem SDK is ok, but the link to Java is false Now the error is initialization of VM after putting Java at bin directory
-
shareware Some open sourced tools for Delphi developers
limelect replied to Patrick PREMARTIN's topic in I made this
Nice answer, but they are given for you to use and advertise So be aware that the source in that case is not OPEN SOURCE. -
shareware Some open sourced tools for Delphi developers
limelect replied to Patrick PREMARTIN's topic in I made this
You are using some paid components. Is it advertising or free source? -
I hope I explained my problem with the listview I have 2 pictures and 2 text Adding text ,the text items is OK, but Adding 2 pictures is the problem PListItemData = ^TListItemData; TListItemData = record theString: string; ThePicture: TBitmap; end; b: Tbitmap; <<<< is created at oncreat. var ClipItem: TListItem; ListItemData: PListItemData; while not FDQuery2.Eof do begin ------ process Query ClipItem := lvClip.Items.Insert(0); New(ListItemData); try ListItemData.theString := s.Text; <<< OK if ContainsText(s.Text, 'Picture') then begin b.Assign(nil); BlobField := FDQuery2.FieldByName('Image') as TBlobField; Stream := FDQuery2.CreateBlobStream(BlobField, bmRead);<<< read the picture b.LoadFromStream(Stream); ListItemData.ThePicture := TBitmap(b); <<<< get also the picture FreeAndNil(Stream); end; ClipItem.Data := ListItemData; except Dispose(ListItemData); end; FDQuery2.Next; end; No problem, no leak BUT !!!! Now to the problem of looping twice PListItemData(lvClip.Items[0].data).ThePicture <<<< first picture PListItemData(lvClip.Items[0].data).TheString <<< first text OK Second time in the loop PListItemData(lvClip.Items[1].data).ThePicture <<< got second picture PListItemData(lvClip.Items[1].data).TheString <<< second text OK But now PListItemData(lvClip.Items[0].data).ThePicture got the second picture SO, more explanation. The first item got the second picture!!! But the text is OK it has 2 texts no problem On the breakpoint, I see the watch list as PListItemData(lvClip.Items[0].data).ThePicture PListItemData(lvClip.Items[0].data).TheString PListItemData(lvClip.Items[1].data).ThePicture PListItemData(lvClip.Items[1].data).TheString