Jump to content

XylemFlow

Members
  • Content Count

    75
  • Joined

  • Last visited

Everything posted by XylemFlow

  1. Is anyone else experiencing issue getting the documentation (help files) to load online? The pages take ages to load and will often say gateway timed out. https://docwiki.embarcadero.com/Libraries/Athens/en/Main_Page
  2. XylemFlow

    Delphi Documentation website issues

    Thanks for the update. Do you have a link to an official comment or something?
  3. XylemFlow

    3D render engine that works with Delphi

    FMX has built in 3D capability. Just add a new multi device form and select 3D form and go from there. Or is that not functional enough for your needs? http://docwiki.embarcadero.com/RADStudio/Athens/en/FireMonkey_3D
  4. I have some code that loads a png image into a TBitmap and saves it again. However, the output is not the same. The quality of the image seems to deteriorate every time the previous image is loaded and then saved again. I have attached the PNG image, which contains an alpha channel. The original image has a smooth gradient, but the last one clearly doesn't with clear banding. Does anyone know why this may be? I can perhaps understand why the 2nd image may be different since some aspects of the original PNG may not be supported, but I can't understand why subsequent images would vary to the 2nd image. This would indicate that Delphi FMX cannot correctly load an image that it saved. I'm running on Windows 32 bit and using Delphi 11.2 with default project settings. I'm comparing the images by viewing in Gimp and also by comparing in WinMerge. Even the file sizes vary. procedure TForm1.Button1Click(Sender: TObject); var bmp : TBitmap; i : Integer; name : String; begin bmp := TBitmap.Create; name := 'whiteglower_8bit'; for i := 1 to 4 do begin bmp.LoadFromFile(name + IntToStr(i) + '.png'); bmp.SaveToFile(name + IntToStr(i+1) + '.png'); end; bmp.Free; end;
  5. XylemFlow

    Loading and Saving PNG into TBitmap changes the image

    For my application it's very unlikely that image data would not need to be displayed so I wouldn't save much by doing it on demand. At least I would only need to do it for images containing an alpha channel though. It's true that the stream data is compressed. However, the original image in this case was bit depth 64, which FMX converts to bit depth 32 when loaded. I didn't share that version because it was over 1.2MB, whereas the 32bit version was only 100KB. So if I save it as a stream when it first gets loaded it would still be quite large. I may therefore save it to a stream after it gets loaded into the TBitmap, which would mean that it would still suffer from one level of degradation, but at least it wouldn't continue to lose quality each time the binary was loaded and saved, and would use less memory.
  6. XylemFlow

    Loading and Saving PNG into TBitmap changes the image

    Thank you. The problem is that storing as TMemoryStream requires reading into a TBitmap each time it needs displaying. That would require too much delay for real time graphics. I could keep a copy of each image as a stream and a bitmap but that would double up the memory requirements. That may be the only option though.
  7. XylemFlow

    Loading and Saving PNG into TBitmap changes the image

    Attached is a WebP animation showing the first 25 load / save cycles. Untitled.webp
  8. XylemFlow

    Loading and Saving PNG into TBitmap changes the image

    Thanks for the idea. I will look into it. The worst thing is that the issue also happens with TBitmap.LoadFromStream and TBitmap.SaveToStream. This is not surprising since that's what the file load and save functions are using. Note that TBitmap.SaveToStream by default saves as PNG data. Below is code that demonstrates this. I have also attached the resulting first few images, and the last one after 40 load/save cycles showing the issue very clearly. procedure TForm1.Button2Click(Sender: TObject); var bmp : TBitmap; i : Integer; name : String; strm : TMemoryStream; begin bmp := TBitmap.Create; name := 'whiteglower_8bit'; bmp.LoadFromFile(name + '1.png'); strm := TMemoryStream.Create; for i := 1 to 40 do begin strm.Seek(0, 0); bmp.SaveToStream(strm); strm.Seek(0, 0); bmp.LoadFromStream(strm); bmp.SaveToFile(name + IntToStr(i+1) + '_stream.png'); end; bmp.Free; strm.Free; end; This is closer to my use case. My application allows users to save their project in a binary file, which can contain image data like this as well as other data. LoadFromStream and SaveToStream are used to load and save the image data. Each time the user loads a project to work on it and saves it, the quality of the image deteriorates (when alpha channels are used as they often are). This is true whether or not the user modified the image data. This is very bad and I need to find a fix soon if possible. I had assumed incorrectly that saving and loading image data would not change the image data.
  9. XylemFlow

    Loading and Saving PNG into TBitmap changes the image

    No, as I said I'm using Delphi 11.2.
  10. FMX mostly does a very good job of antialiasing graphics, however I notice that quality of TCanvas.DrawBitmap is poor when the destination rect is smaller than the source rect. I'm running on Windows for now. This is especially obvious when the image contains thin lines as the subsampling causes parts of the lines to disappear. I'm looking for a way to improve the quality without compromising too much on runtime. So ideally I'd like it to be done on the GPU. I feel that this is a job that the GPU should be doing. Below is an example with 3 different methods. The last method is my own code, which shows what I'm trying to achieve but is not done on the GPU and so is not as fast as I'd like it to be. It also won't work if I want to include some rotation as well as scale using TCanvas.Matrix. I have also tried changing the HighSpeed flag in the DrawBitmap function, but it doesn't seem to make a difference (it does when upscaling an image but not when downscaling). See the attached project code example. Is this something that GPUs can normally do and if so, why isn't DrawBitmap doing it? Is there an alternative that will also work on different platforms? If I reduce an image in something like Inkscape it will do a much better job, although I'm not sure if the GPU is being used for the downsampling. Draw_bitmap_small.zip
  11. I need to be able to draw several objects to a form or TImage TCanvas, including lines, circles, polygons, text, etc and have them drawn as a group with a single opacity. If I draw them separately then it won't look correct where they overlap. I currently do this by drawing the objects to an offscreen TBitmap canvas with full opacity and then drawing the TBitmap to my form or TImage TCanvas with the opacity I want. However, this is slower and uses more memory. I'd also like to use Skia in future, but I understand that drawing to offscreen bitmaps is slower since it doesn't use the GPU. Is there a method to group objects in this way in default FMX or Skia without using an offscreen bitmap?
  12. XylemFlow

    Group a collection of drawn objects to have a single opacity

    Unfortunately I need to draw everything directly on a single TCanvas. I cannot do it by layering controls on top of each other. One reason is because I need to export the resulting image. By sharing the same opacity I mean that they should be semi transparent and so show previously drawn objects underneath
  13. If you want to change the style of the whole window then it's easier to download a theme style. You can download FMX styles or a VCL style and convert it to a VCL style using Bitmap Style Designer. You can then modify the style if needed. The critical part of the style for the window is windowborderstyle.
  14. XylemFlow

    Issue with TNumberBox

    When I select all the text in a TNumberBox (Ctrl+A or drag over the text) and hit Delete, the value gets reset to the Min value and the OnChange event is triggered. This is strange because clicking at the end of the number text and deleting all the characters one at a time until none are left doesn't do the same. A user is likely to want to quickly delete the text, type in a new value and hit enter. However, this doesn't work because the value automatically gets reset to the Min value when all the text is deleted at once. Is there any way I can prevent that? Note that I am running for Windows 32-bit.
  15. XylemFlow

    Issue with TNumberBox

    It seems that this isn't only an issue with TNumberBox. TSpinBox does it too. I think anything descended from TCustomEdit. My best guess is that the control is validated when deleting selected text because there is no caret shown.
  16. XylemFlow

    Issue with TNumberBox

    Thanks Mike. Setting VertIncrement to 0 solves the first issue. I have also set HorzIncrement to 0 so that dragging selects the text without changing the value. Unfortunately that means that the arrow keys and mouse wheel no longer increment the value, but I was able to implement that myself using the KeyDown and MouseWheel events. So yes, it is a bit of a mess, but otherwise it works ok. One advantage is that it automatically prevents non numeric characters and supports copy and paste. Ctrl+A does work for me.
  17. XylemFlow

    Issue with TNumberBox

    I've not tried VCL, only FMX. Interesting that it's not happening in VCL though. Also, I'm using 11.2. I have some boxes ranging from -360 to 360, some from -180 to 180 and some from 0 to 100. They all behave the same way.
  18. I have created a TFrame at design time using the form designer. I then create several instances of the frame at run time. Is there a way to set a property of the underlying TFrame for all instances at once instead of having to iterate over all instances? For example, when a user changes the language at run time the captions and hints of the buttons in the TFrame need to be updated for all instances.
  19. I have set the form's Transparent property to True. I have a TImage covering the form, which also has some fully transparent areas. When these transparent areas are clicked the window underneath is selected and the form loses focus. I'd like the form to keep focus and the TImage OnMouseDown event to trigger. So far the only solution I've found is to place a slightly opaque TRectangle over the form, however this is not ideal because it requires unnecessary alpha blending and also changes the colours slightly.
  20. XylemFlow

    User Drawing of Lines and Curves

    Funny. That bug was reported by me, but I hadn't considered that it would cause problems in my demo.
  21. XylemFlow

    Round corners on FMX form

    I would set the Form's Transparency property to True. https://docwiki.embarcadero.com/Libraries/Sydney/en/FMX.Forms.TForm.Transparency Now you can put a TRectangle on the form and align it to client. Set its XRadius and YRadius to round the corners. Set it's Fill colour to that of the form. The rounded areas in the corners will not be considered part of the form. Clicking them will select object behind the form. The down side is that the form's title bar will be missing, but you could perhaps recreate it with some additional controls. But for a splash screen I guess you don't want the title bar anyway. I have the opposite problem. I have a transparent form and want the transparent areas to be considered part of the form and not select windows behind. The best way I've found is to place a very slightly opaque TRectangle over the form, but this isn't ideal. I'd like a method to make it fully transparent.
  22. This is a rather complex issue that I need help resolving. TImage Mouse Move and Mouse Up events are not triggered after showing a modal window from a TMainMenu item, but only when a certain style is applied to the form. Attached is a project for replicating the issue. Mouse events are recorded with incrementing counters. Any help would be appreciated. I'm using Delphi 11.2 and running in Windows 10. Steps: 1. Build for Windows 32-bit and run 2. Select Dark mode with the check box, which will apply the style to the form 3. Click Show 2nd Form in the File menu, which will show a 2nd form as a modal window 4. Close the 2nd form. The main form will regain focus 5. Move the cursor over the image and the counter won't increment Observations: 1. The Mouse Down event is triggered after closing the 2nd window, but the Mouse Up event isn't. This causes a miss match in the counters. 2. In the default light mode the menu items activate on mouse up, but in dark mode they activate on mouse down. Perhaps the main menu is still owning the mouse up and mouse move events somehow after closing the window because of this? 3. A TMenuBar does not have the same issue, even though its items are activated on mouse down 4. I can't find anything in the style editor for the dark style that I could edit to fix the issue. 5. I could try putting something in the main form's OnActivate event to force the Image to regain ownership of the mouse events, but nothing I try seems to work. Dark Mode Demo.zip
  23. XylemFlow

    Issue with TMenuBar and Alt key

    I'm using the Alt key in my application in an unusual way. It's used to modify how an object is dragged around on a canvas. The issue is that when pressing the Alt key after clicking down on the mouse button, the mouse up event and key up events are not triggered. I assume that this has something to do with accelerator keys for the TMenuBar. However, I don't want accelerator keys for the menu and they don't work in FMX anyway. I had the same issue in a previous version of my application that was developed in VCL. That was solved easily with the following, which then prevents the menu from reacting to the Alt key. procedure TForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin // Prevent Alt key selecting the menu if Shift = [ssAlt] then begin Key := 0; Exit; end; // Other key processing code end; However, the same doesn't work in FMX with TMenuBar. I've tried setting Key to 0 and KeyChar to #0 but the issue remains. Note that the same issue does not happen when using TMainMenu, but I'm forced to use TMenuBar for various reasons. Does anyone have a solution? I'm running in Windows 32-bit but would also want it to work for macOS.
  24. XylemFlow

    Issue with TMenuBar and Alt key

    https://quality.embarcadero.com/browse/RSP-42144 Thanks
  25. XylemFlow

    Issue with TMenuBar and Alt key

    Regarding the above code edit. I decided it was better to just comment out that whole part and just leave the following since I don't want the menu to ever interact with the Alt key. Result := DefWindowProc(hwnd, uMsg, wParam, lParam);
×