Guest Posted January 22, 2019 hello, do you know if is it possible to build a pixel-perfect application in FMX without use low-level API (bypassing it) as GLEs surface on Android or similar? Because I remember some years ago was impossible to do integer based bitmap pixel-perfect appearance with FMX (floating point surface). Any hint? Thank you Roberto Share this post Link to post
David Heffernan 2353 Posted January 22, 2019 Define "pixel perfect" please Share this post Link to post
Guest Posted January 22, 2019 do you remember how to edit sprites in C64 or deluxe paint II for Amiga? 🙂 I mean having a integer grid matching the screen without do a DPI aware linear/bilinear filter conversion. If I put a 128x128pixel bitmap, the canvas should fill 128x128 pixels with the original bitmap without scale it or artifacts. Higher DPI will result in a smaller image of course. Instead FMX works with scale proportions as PDF for example. I don't know if my explain is good. Thanks anyway. Share this post Link to post
Cristian Peța 107 Posted January 22, 2019 If you meant using TCanvas, this was possible at least when mobile compilers rolled out. The way to do this changed a little over time but now you need to apply a transformation matrix to the canvas to reverse scaling and all you paint using canvas will match 1:1. There was needed also a translation of (-0.5, -0.5) in that matrix because you needed to use (0.5, 0.5) to use only one pixel. I don't know if this is the case also now. Share this post Link to post
Guest Posted January 22, 2019 Last time I have tried this method the result was not optimal. Thus it is too slow. Should be cool have a FMX update with direct canvas access methods. Share this post Link to post
Rollo62 539 Posted January 23, 2019 Still unsure what you mean. If you mean accessing Bitmaps, this is done by mapping the Bitmap first, so to be able to access single pixels. This should have no pixel scaling problems. Share this post Link to post
Cristian Peța 107 Posted January 23, 2019 (edited) Actually I changed my code some years ago and now I'm painting on a bitmap scaled with Canvas.Scale (an UI Canvas) and then use Canvas.DrawBitmap() to draw UI. Edited January 23, 2019 by Cristian Peța UI Canvas 1 Share this post Link to post
Alexander Brazda 1 Posted February 26, 2019 For 2d/3d game better use DirectX/OpenGL libraries instead of canvas drawing For controls, painting is done using canvas, so speed it limited. Yo can draw component to a buffer using DirectX/OpenGL surfaces (for complex compositions) and transfer to canvas control, using some buffering to avoid redraw Forms and controls can be scaled from desing dpi to device dpi, check Handle.Scale from yout form For test pixel perfect, I made a simple app to place a Button, Label and TRectangle to get coordinates & dimension of the shape (no style) to see if they are scaled some way. TRectangle is positionated at (16,148) with a size of 64x64. I run on my samsung galaxy tab, click on button to update Label text with the rectangle position and size and compare with screen shot. Result, rectangle is positionated at 16,148 pixels in clientarea and is 64x64 pixels size, so no scaling has been done. Rectangle is show width 1 px arround the shape as desing. 1 Share this post Link to post
Guest Posted February 26, 2019 ok, I'm used to deploy SDL2 under arm embedded, it's not for speed, but to obtain high quality bitmap based surfaces under FMX. IMHO Fmx should implement methods to do direct canvas drawing without scale, in a easy way, as TGraphics32 for example. Share this post Link to post