cancel
Showing results for 
Search instead for 
Did you mean: 

Chrom-ART Transparent rectangles / fills?

contact239955_st
Associate II
Posted on March 21, 2018 at 20:20

Hi, I've been working on a UI for past couple weeks,

I've successfully created functionality for drawing bitmaps (with or without alpha), anti-aliased fonts and solid rectangles / lines using Chrom-ART / DMA2D

I am however currently unsure how to do rectangle fills with transparency. I assumed that DMA2D_R2M would accept a ARGB color and layer configurations, however that was not the case.

Can someone explain in rough lines how I can fill a rectangle, that contains an alpha channel, over an existing drawn area?

Thanks

http://preview.ibb.co/htzuzc/IMG_20180321_202jpg

My current bitmap/font character drawing function:

void

LCD

::

DMA_DrawBitmap

(

void

*pSrc

,

void

*pDst

,

uint32_t

xSize

,

uint32_t

ySize

,

uint32_t

ColorMode

,

uint32_t

inputAlpha

,

uint32_t

inputOffset) {

hDma2dHandler

.

Init

.

Mode

=

DMA2D_M2M_BLEND

;

hDma2dHandler

.

Init

.

ColorMode

=

hLtdcHandler

.

LayerCfg

[

0

].

PixelFormat

;

hDma2dHandler

.

Init

.

OutputOffset

=

SCREEN_WIDTH

- xSize

;

hDma2dHandler

.

LayerCfg

[

0

].

AlphaMode

=

DMA2D_NO_MODIF_ALPHA

;

hDma2dHandler

.

LayerCfg

[

0

].

InputColorMode

=

hLtdcHandler

.

LayerCfg

[

0

].

PixelFormat

;

hDma2dHandler

.

LayerCfg

[

0

].

InputAlpha

=

0

;

hDma2dHandler

.

LayerCfg

[

0

].

InputOffset

=

SCREEN_WIDTH

- xSize

;

/* Foreground Configuration */

hDma2dHandler

.

LayerCfg

[

1

].

AlphaMode

=

DMA2D_NO_MODIF_ALPHA

;

hDma2dHandler

.

LayerCfg

[

1

].

InputAlpha

= inputAlpha

;

hDma2dHandler

.

LayerCfg

[

1

].

InputColorMode

= ColorMode

;

hDma2dHandler

.

LayerCfg

[

1

].

InputOffset

= inputOffset

;

hDma2dHandler

.

Instance

=

DMA2D

;

/* DMA2D Initialization */

if

(HAL_DMA2D_Init(&

hDma2dHandler

) ==

HAL_OK

) {

if

(HAL_DMA2D_ConfigLayer(&

hDma2dHandler

,

0

) ==

HAL_OK

&& HAL_DMA2D_ConfigLayer(&

hDma2dHandler

,

1

) ==

HAL_OK

) {

if

(HAL_DMA2D_BlendingStart(&

hDma2dHandler

,

(

uint32_t

) pSrc

,

(

uint32_t

) pDst

,

(

uint32_t

) pDst

,

xSize

,

ySize) ==

HAL_OK

) {

HAL_DMA2D_PollForTransfer(&

hDma2dHandler

,

500

)

;

}

}

}

}

And rectangle fill function:

void

LCD

::

DMA_FillRect

(

void

*pSrc

,

void

*pDst

,

uint32_t

xSize

,

uint32_t

ySize

,

uint32_t

ColorMode) {

/* Configure the DMA2D Mode, Color Mode and output offset */

hDma2dHandler

.

Init

.

Mode

=

DMA2D_M2M_PFC

;

hDma2dHandler

.

Init

.

ColorMode

=

hLtdcHandler

.

LayerCfg

[

0

].

PixelFormat

;

hDma2dHandler

.

Init

.

OutputOffset

=

SCREEN_WIDTH

- xSize

;

/* Foreground Configuration */

hDma2dHandler

.

LayerCfg

[

1

].

AlphaMode

=

DMA2D_NO_MODIF_ALPHA

;

hDma2dHandler

.

LayerCfg

[

1

].

InputAlpha

=

0xFF

;

hDma2dHandler

.

LayerCfg

[

1

].

InputColorMode

= ColorMode

;

hDma2dHandler

.

LayerCfg

[

1

].

InputOffset

=

0

;

hDma2dHandler

.

Instance

=

DMA2D

;

/* DMA2D Initialization */

if

(HAL_DMA2D_Init(&

hDma2dHandler

) ==

HAL_OK

) {

if

(HAL_DMA2D_ConfigLayer(&

hDma2dHandler

,

1

) ==

HAL_OK

) {

if

(HAL_DMA2D_Start(&

hDma2dHandler

,

(

uint32_t

) pSrc

,

(

uint32_t

) pDst

,

xSize

,

ySize) ==

HAL_OK

) {

HAL_DMA2D_PollForTransfer(&

hDma2dHandler

,

500

)

;

}

}

}

}

graphics lcd ui chrom-art dma2d

5 REPLIES 5
contact239955_st
Associate II
Posted on March 26, 2018 at 13:38

Anyone?

Tilen MAJERLE
ST Employee
Posted on March 26, 2018 at 13:42

Hello

Sleziak.Marcin

‌,

R2M with blending is directly not supported. However, you can do these steps:

  1. Use R2M mode and fill your rectangle memory outside layers
  2. Perform M2M with blending

    1. For front layer set memory of your rectangle you just filled
    2. For back layer set memory position where you want to put your rectangle
    3. Set front layer alpha for transparency value of whole layer

Best regards,

Tilen

Tilen MAJERLE
ST Employee
Posted on March 26, 2018 at 13:50

Hello

Sleziak.Marcin

‌,

this is the only way. Any operation with transparency is normally done in pixel2pixel conversion between 2 memory addresses (2 layers), thus R2M_Blending mode is not supported and alpha channel is ignored.

Which STM32 do you use in this project?

Best regards,

Tilen

Posted on March 26, 2018 at 13:48

Hi

Majerle.Tilen

, thank you for your reply!

That's currently the work-around I'm using, however this requires me to have a 3rd buffer allocated just for transparent rectangle fill operations.

Is this something that is technically not possible or just not documented?

Best wishes,

Posted on March 26, 2018 at 13:56

All right, that makes sense.

I'll try to optimize my 3rd buffer memory usage by using A4 color mode + a CLUT (If that makes sense?).

I'm using the F746

Best wishes,