This hands on is based on the evkmimxrt1170_pxp_lab_cm7.zip which is from
https://community.nxp.com/t5/i-MX-RT1170-CAS-Training/PXP-Multiple-Files/ta-p/1178709
this hands on give an example to understand pxp basic concept like letterbox background color, rotation, ps buffer coordination definition, output buffer coordination definition more clear
No Roation
This test is based on no rotation, so define as below
#define LAB1_BIT_BLIT_NO_ROTATION
This demo output is that the rabbit picture shows on the upper left corner of lcd, and the offset width and height is 100
#ifdef LAB1_BIT_BLIT_NO_ROTATION
PXP_ps_bitblit(
// input
(void*)bmp_rabbit,
PIXEL_BYTES,
BMP_RABBIT_WIDTH,
BMP_RABBIT_HEIGHT,
// output
s_BufferLcd[curLcdBufferIdx],
DEMO_PANEL_WIDTH,
DEMO_PANEL_HEIGHT,
100, // output offset x
100, // output offset y
kPXP_No_Rotate);
#endif
in this lab sample code, the background is set to black,
PXP_SetProcessSurfaceBackGroundColor(APP_PXP, 0U);
The output is
If we want to set the background to lighter blue, this is what I want to get
then I modify the code to
PXP_SetProcessSurfaceBackGroundColor(APP_PXP, 0xFFF0U);
But we get the same output like, without any difference
Check the code, find that the original code
void PXP_ps_sub_region_bitblit(…)
{ …..
outputBufferConfig.width = sub_region_width;
outputBufferConfig.height = sub_region_height;
……
}
This means that the output buffer width and height are the same as the picture width and height, so whatever background color you set, you couldn’t find anything difference, then change the output buffer width and height is the same as lcd width and height
void PXP_ps_sub_region_bitblit(…)
{ …..
outputBufferConfig.width = output_width;
outputBufferConfig.height= output_height;
……
}
Then the output change to
We can find the color on the top of display is still black and this isn’t what I need, still tracing the code
void PXP_ps_sub_region_bitblit(…)
{ …..
// Output buffer
outputBufferConfig.buffer0Addr = (uint32_t)output_buffer + output_offset_y * output_width * pic_bytes_per_pixel + output_offset_x * pic_bytes_per_pixel
……
}
output_buffer is defined as lcd buffer start address, here the output buffer start address isn’t defined as lcd buffer start address(output_buffer), this is offset of lcd buffer start address, so change it like
void PXP_ps_sub_region_bitblit(…)
{ …..
// Output buffer
outputBufferConfig.buffer0Addr = (uint32_t)output_buffer
……
}
Then the output is like
The output picture move to the upper left corner without offset, but this demo defines the offset is 100
void PXP_ps_sub_region_bitblit(…)
{ …..
// PS buffer
PXP_SetProcessSurfacePosition(APP_PXP,0,0,BMP_RABBIT_WIDTH - 1U,
BMP_RABBIT_HEIGHT - 1U);
…..
}
In the original code, the PS buffer offset is 0, because the ps buffer start address is the same as the output buffer start address, and output buffer start address is offset + lcd output buffer start address, so set the PS output offset is 0, but I change the output buffer start address is the same as lcd buffer start address, so change the code
void PXP_ps_sub_region_bitblit(…)
{ …..
uint32_t psUlcX = output_offset_x;
uint32_t psUlcY = output_offset_y;
uint32_t psLrcX, psLrcY;
psLrcX = psUlcX + sub_region_width - 1U;
psLrcY = psUlcY + sub_region_height- 1U;
// PS buffer
PXP_SetProcessSurfacePosition(APP_PXP,psUlcX,psUlcY,psLrcX,psLrcY);
…..
}
The output is
\
Now this is what we need
Roation
Set Macro to #define LAB2_BIT_90_DEGREE_ROTATION
The output is
When rotation is 90 degree and width is wider than the output height, the display part will be cut, so change the code from
Before
void PXP_ps_sub_region_bitblit(…)
{ …..
outputBufferConfig.width = output_width;
outputBufferConfig.height= output_height;
…..
}
To
void PXP_ps_sub_region_bitblit(…)
{ …..
if (rotate == kPXP_Rotate90)
{
outputBufferConfig.width = output_height; /*Joan*/
outputBufferConfig.height = output_width; /*Joan*/
}
else
{
outputBufferConfig.width = output_width; /*Joan*/
outputBufferConfig.height = output_height; /*Joan*/
}…..
}
Because this demo only shows no rotation and 90 degree rotation, if customer needs 270 degree, 180 degree, can add by themselves
記事全体を表示