{"id":473,"date":"2024-03-06T17:49:50","date_gmt":"2024-03-06T16:49:50","guid":{"rendered":"https:\/\/melander.dk\/graphics32\/?page_id=473"},"modified":"2024-03-06T17:49:50","modified_gmt":"2024-03-06T16:49:50","slug":"paint-stages","status":"publish","type":"page","link":"https:\/\/melander.dk\/graphics32\/paint-stages\/","title":{"rendered":"Paint Stages"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">Paint Stages<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">An order in which TImage32 blends layers and bitmap image to its back-buffer is specified by paint stages.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, the default sequence of operations includes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Clearing the visible area of the background, that is the parts of the buffered area which are not covered by the bitmap image, or the whole buffer, if the bitmap image is not in dmOpaque draw mode;<\/li>\n\n\n\n<li>Drawing the dotted frame around the control boundaries (design-time only);<\/li>\n\n\n\n<li>Drawing the scaled bitmap image;<\/li>\n\n\n\n<li>Framing the area of the scaled bitmap image with the dotted frame (design-time only);<\/li>\n\n\n\n<li>Drawing layers;<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">It is possible to change the order in which stages execute at run-time, add new stages, delete old ones, etc., using the <a href=\"https:\/\/graphics32.github.io\/Docs\/Units\/GR32_Image\/Classes\/TCustomImage32\/Properties\/PaintStages.htm\">PaintStages<\/a> property of TImage32, which is basically a dynamic indexed list of stages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a>TPaintStage Record<\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a><\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a>Each paint stage is defined with a <\/a><a href=\"https:\/\/graphics32.github.io\/Docs\/Units\/GR32_Image\/Types\/TPaintStage.htm\">TPaintStage<\/a> record:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>type<\/strong> TPaintStage = <strong>record<\/strong><br>&nbsp;&nbsp;DsgnTime: Boolean;<br>&nbsp;&nbsp;RunTime: Boolean;<br>&nbsp;&nbsp;Stage: Cardinal; \/\/ a PST_* constant<br>&nbsp;&nbsp;Parameter: Cardinal; \/\/ an optional parameter<br><strong>end<\/strong>;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">where the Stage member holds one of the <a href=\"https:\/\/graphics32.github.io\/Docs\/Units\/GR32_Image\/Constants\/Paint%20Stage%20Constants.htm\">Paint Stage Constants<\/a> and defines the action associated with the stage.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">All stages include additional parameter, which may be ignored or may be used to store additional stage options. For example, PST_DRAW_LAYERS stage uses its parameter as a 32-bit mask to filter out invisible layers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By default, TImage32 contains the following stages:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>#<\/th><th>DsgnTime<\/th><th>RunTime<\/th><th>Stage<\/th><th>Parameter<\/th><\/tr><tr><td>0<\/td><td>True<\/td><td>True<\/td><td>PST_CLEAR_BACKGND<\/td><td>not used<\/td><\/tr><tr><td>1<\/td><td>False<\/td><td>True<\/td><td>PST_CONTROL_FRAME<\/td><td>not used<\/td><\/tr><tr><td>2<\/td><td>True<\/td><td>True<\/td><td>PST_DRAW_BITMAP<\/td><td>not used<\/td><\/tr><tr><td>3<\/td><td>False<\/td><td>True<\/td><td>PST_BITMAP_FRAME<\/td><td>not used<\/td><\/tr><tr><td>4<\/td><td>True<\/td><td>True<\/td><td>PST_DRAW_LAYERS<\/td><td>$80000000<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">See &#8216;<a href=\"https:\/\/graphics32.github.io\/Docs\/Additional%20Topics\/Using%20TImage32\/Using%20Layers.htm\">Using Layers<\/a>&#8216; for an explanation of the parameter value in PST_DRAW_LAYERS stage.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a>Customizing TImage32 at Run-Time<\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A PST_CUSTOM stage deserves a little bit deeper explanation. It causes the control to issue an <a href=\"https:\/\/graphics32.github.io\/Docs\/Units\/GR32_Image\/Classes\/TCustomImage32\/Events\/OnPaintStage.htm\">OnPaintStage<\/a> event, thus allowing to change TImage32 behavior at run-time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <a href=\"https:\/\/graphics32.github.io\/Docs\/Units\/GR32_Image\/Classes\/TCustomImage32\/Events\/OnPaintStage.htm\">OnPaintStage<\/a> event is of a TPaintStageEvent type:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>type<\/strong> TPaintStageEvent = <strong>procedure<\/strong>(Sender: TObject; Dest: TBitmap32; StageNum: Cardinal) <strong>of<\/strong> <strong>object<\/strong>;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the event handler, the application can perform some custom operations over the back-buffer of the control.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note, that by default, TImage32 does not generate <a href=\"https:\/\/graphics32.github.io\/Docs\/Units\/GR32_Image\/Classes\/TCustomImage32\/Events\/OnPaintStage.htm\">OnPaintStage<\/a>. In order to make it do so, you have to insert a new stage in the <a href=\"https:\/\/graphics32.github.io\/Docs\/Units\/GR32_Image\/Classes\/TCustomImage32\/Properties\/PaintStages.htm\">PaintStages<\/a> list, and set its Stage to PST_CUSTOM, or change one of the existing stages, for example:<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Paint Stages An order in which TImage32 blends layers and bitmap image to its back-buffer is specified by paint stages. For example, the default sequence of operations includes: It is possible to change the order in which stages execute at<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-473","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/melander.dk\/graphics32\/wp-json\/wp\/v2\/pages\/473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/melander.dk\/graphics32\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/melander.dk\/graphics32\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/melander.dk\/graphics32\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/melander.dk\/graphics32\/wp-json\/wp\/v2\/comments?post=473"}],"version-history":[{"count":1,"href":"https:\/\/melander.dk\/graphics32\/wp-json\/wp\/v2\/pages\/473\/revisions"}],"predecessor-version":[{"id":474,"href":"https:\/\/melander.dk\/graphics32\/wp-json\/wp\/v2\/pages\/473\/revisions\/474"}],"wp:attachment":[{"href":"https:\/\/melander.dk\/graphics32\/wp-json\/wp\/v2\/media?parent=473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}