Jump to content
Sign in to follow this  
Guest

pixel-perfect bitmap FMX app

Recommended Posts

Guest

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
Guest

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

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

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

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 by Cristian Peța
UI Canvas
  • Like 1

Share this post


Link to post

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. 

 

  • Like 1

Share this post


Link to post
Guest

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×