FTDI Community
General Category => Discussion - Software => Topic started by: sergpenshin on February 15, 2021, 11:56:17 AM
-
Hi everyone.
I am using FT811 chip and ran into a problem how to use CMD_SCALE correctly to get images larger than 511x511 pixels.
The display witch i'm using has 800х600 pixels and working with Bitmaps I add BITMAP_LAYOUT_H and BITMAP_SIZE_H.
Everything works correctly and I can upload images with a resolution greater than 512x512.
But if I use the SCALE() command to resize an image to get over than 511x511, for example the image 160x120 with scale factor of 4, the picture is cropped as if I havn't used BITMAP_LAYOUT_H and BITMAP_SIZE_H at all.
Here is the code, please tell me what I do wrong?
int16_t imgWidth = 160;
int16_t imgHeight = 120;
App_WrCoCmd_Buffer(phost,COLOR_RGB(255,255,255));
App_WrCoCmd_Buffer(phost,BITMAP_SOURCE(0));
App_WrCoCmd_Buffer(phost,BITMAP_LAYOUT(RGB565,imgWidth*2,imgHeight));
App_WrCoCmd_Buffer(phost,BITMAP_LAYOUT_H((imgWidth*2)>>10,imgHeight>>9));
App_WrCoCmd_Buffer(phost,BITMAP_SIZE(NEAREST,BORDER,BORDER,imgWidth,imgHeight));
App_WrCoCmd_Buffer(phost,BITMAP_SIZE_H(imgWidth>>9,imgHeight>>9));
App_WrCoCmd_Buffer(phost,BEGIN(BITMAPS)); // start drawing bitmaps
Gpu_CoCmd_LoadIdentity(phost);
Gpu_CoCmd_Scale(phost,4*65536, 4*65536);
Gpu_CoCmd_SetMatrix(phost);
App_WrCoCmd_Buffer(phost,VERTEX2F(0,0));
App_WrCoCmd_Buffer(phost, END());
-
Hi,
You can add the same factor to the BITMAP_SIZE and BITMAP_SIZE_H and this should help. Please see below (you can use a variable 'scale' instead to save changing several values if you decide to change the scale)
int16_t imgWidth = 160;
int16_t imgHeight = 120;
App_WrCoCmd_Buffer(phost,COLOR_RGB(255,255,255));
App_WrCoCmd_Buffer(phost,BITMAP_SOURCE(0));
App_WrCoCmd_Buffer(phost,BITMAP_LAYOUT(RGB565,imgWidth*2,imgHeight));
App_WrCoCmd_Buffer(phost,BITMAP_LAYOUT_H((imgWidth*2)>>10,imgHeight>>9));
App_WrCoCmd_Buffer(phost,BITMAP_SIZE(NEAREST,BORDER,BORDER,(imgWidth *4),(imgHeight *4));
App_WrCoCmd_Buffer(phost,BITMAP_SIZE_H((imgWidth *4) >>9,(imgHeight *4) >>9));
App_WrCoCmd_Buffer(phost,BEGIN(BITMAPS)); // start drawing bitmaps
Gpu_CoCmd_LoadIdentity(phost);
Gpu_CoCmd_Scale(phost,4*65536, 4*65536);
Gpu_CoCmd_SetMatrix(phost);
App_WrCoCmd_Buffer(phost,VERTEX2F(0,0));
App_WrCoCmd_Buffer(phost, END());
Best Regards, FTDI Community
-
Thank you very much!
Really my mistake was that I'v added scale factor to the BITMAP_SIZE but have not added it to BITMAP_SIZE_H.