![]() ![]() ![]() Another is to provide some form of output for fields that usually don't show up in the grid, such as BLOB, graphic, and memo fields. A good example is to highlight specific fields or records. Now, you can obviously save as a ‘PNG’ from the bitmap, but the above code shows how to avoid saving a file to disk unless you really need to.There are many reasons you might want to customize the output of a grid. comparison output as PNG from the stream do something with the png stream image '.png') then raise EBitmapSavingFailed.Create( use the codec to save Surface to stream if not TBitmapCodecManager.SaveToStream( procedure TForm1.Button1Click(Sender: TObject) The key part is the TBitmapSurface and TBitmapCodecManager. The following code is an example using two image viewers (and a few save to files to help demonstrate the difference in file size). A simple screen test has gone from over 1mb as a bitmap to around 6kb when saved to PNG using this approach. This is done using the TBitmapCodecManager class. SaveToStream and TBitmapCodecManagerīitmap.SaveToStream doesn’t expose the CodexManager in the same way as it is available automatically with the SaveToFile option so takes a little more work to get a compressed image into the memory stream. Personally I would use PNG as the JPG formats are around the same size on some test I’ve run, but produce a better quality of image, especially when grabbing screenshots. This works really well with even more extensions supported. SaveToFileĬreating a PNG, JPG/JPEG is as simple as calling the Bitmap.SaveToFile with the correct file extension. Thankfully FireMonkey has a really easy to use CodecManager that allows you to SaveToFile or SaveToStream and convert to PNG or JPG across all platforms (which are vastly smaller in size). If you want to send an image via Stream using LiveBindings or want to save an Image to disk or into a database on a device with limited storage however, they are quite large. In FireMonkey, Bitmap is the common currency for working with images. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
June 2023
Categories |