Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TImage32.PaintTo draws "fancy" background #247

Closed
andersmelander opened this issue Apr 23, 2023 · 5 comments
Closed

TImage32.PaintTo draws "fancy" background #247

andersmelander opened this issue Apr 23, 2023 · 5 comments
Assignees
Labels

Comments

@andersmelander
Copy link
Member

          Potentiel bug in `TImage32.PaintTo` in the code of background generation , 

AImage.PaintTo(BackgroundBitmap, BackgroundBitmap.BoundsRect);

As I know transparency tiles are painted to mark presence of alpha channel, and reseved for purly internal use and shouldn't be painted in the external Bitmap32 :

I think it's important to disable dmBlend DrawMode in TImage32.Bitmap before exportation

TransTiles

Originally posted by @lamdalili in #240 (comment)

@andersmelander
Copy link
Member Author

andersmelander commented Apr 23, 2023

As I know transparency tiles are painted to mark presence of alpha channel, and reseved for purly internal use and shouldn't be painted in the external Bitmap32

Yes, that's a bug.
The bug is that the PST_CLEAR_BACKGND paint stage is marked as both a designtime- and a runtime-stage. It should only be marked as a design-time stage. That way it will not be used in PaintTo.

Additionally, the PST_CLEAR_BUFFER paint stage isn't created by default. As far as I can see there's no reason for it to be used when the PST_CLEAR_BACKGND stage is used because PST_CLEAR_BACKGND will completely cover the visible background. Therefore PST_CLEAR_BUFFER can be marked as a run-time paint stage. This way the two paint stages will be mutually exclusive and will not conflict.

I can see that there's some functionality missing in TCustomImage32 with regard to the flattened bitmap produced by PaintTo; It is currently not possible to create a semitransparent flattened bitmap because the background is always opaque with Alpha=255. The reason is that the color of the background is specified with a regular TColor (no alpha) and not a TColor32 (with alpha). I will create a separate issue for that.

I think it's important to disable dmBlend DrawMode in TImage32.Bitmap before exportation

Why?

@andersmelander
Copy link
Member Author

the PST_CLEAR_BUFFER paint stage isn't created by default.

This is documented behavior (see: ExecClearBuffer) but that doesn't mean that it can't be changed.

andersmelander pushed a commit that referenced this issue Apr 23, 2023
The PST_CLEAR_BUFFER paint-stage is now added by default and is marked run-time only.
Refs #247
@andersmelander andersmelander self-assigned this Apr 23, 2023
@andersmelander
Copy link
Member Author

I confused Delphi IDE design-/run-time with application design-/run-time in my last commit so I have deleted the commit.

I will need to extend the paint stage record so it's possible to differentiate between the three possible draw modes:

  • Design-time
  • Run-time with "stuff" (fancy background)
  • Run-time without "stuff" (basically just the image data).

@lamdalili
Copy link
Contributor

lamdalili commented Apr 23, 2023

Why?

Setting TImage32.Bitmap DrawMode to dmOpaque hides Paint Stages before PST_DRAW_BITMAP and paints corretely the contenent of TImage32, maybe it's not the best solution but actually gives the expected image. I think the issue is due to the "recenly" internal styles designed for the background and should be disabled when entring in PaintToMode.

DefaultCheckersColors: array[TBackgroundCheckerStyle] of TBackgroundOptions.TCheckersColors =

@andersmelander
Copy link
Member Author

Setting TImage32.Bitmap DrawMode to dmOpaque hides Paint Stages before PST_DRAW_BITMAP

I see. IMO that is just a workaround. I would rather fix the problem so we don't need workarounds.

andersmelander pushed a commit that referenced this issue Apr 23, 2023
…ad we now have a "mask set" that indicates what the paint stage should be used for: psmRunTime, psmDesignTime and psmExport.

psmRunTime replaces the DsgnTime flag, psmDesignTime replaces the DsgnTime flag and the new psmExport flag indicates if the paint stage should be drawn by the PaintTo method.
Only the PST_DRAW_BITMAP and PST_DRAW_LAYERS paint-stages have the psmExport mask flag set by default.
Fixes #247
Fixes #248
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants