FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: SCALE() command for FT81x  (Read 75 times)

sergpenshin

  • Newbie
  • *
  • Posts: 2
    • View Profile
SCALE() command for FT81x
« 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?
Code: [Select]
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());


Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 569
    • View Profile
Re: SCALE() command for FT81x
« Reply #1 on: February 16, 2021, 11:10:00 AM »

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)

Code: [Select]
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

Logged

sergpenshin

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: SCALE() command for FT81x
« Reply #2 on: February 16, 2021, 01:51:14 PM »

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.
Logged