472 views
in Getting started by
Hi, I'm using Image view to show a multi-frame png bitmap and I'm able to show only frames below 3 or 4 (depending on how I arrange frames in the file e.g. 1x6, 2x3, 3x2), so when I select frames from 4 or 5 and above the view just stays empty. I've tried to rearrange my frames in the file as well as use Warp Image view, but result is the same. What am I doing wrong?

1 Answer

0 votes
by
Hi,

are there any messages on the console window? Let us know...

Furthermore, which target are you using?

Best regards,

Manfred.
by
Manfred, no messages in the console. I'm using STM32F412 target, but it does the same thing in the prototyper.
by
Can you provide a reduced example (you can upload a packed project here)?
by

Please find it here

by

Hi,

thanks for the example project - the reason for the "missing frame" is the bitmap resource that you are using:

As you can see, it contains only 5 frames with the size 118x118 pixel. The file menu-icons.png contains a bitmap with 118x707 pixel - which is missing one pixel row to contain 6 frames. In this case the bitmap should have 118x708 pixel.

I hope this helps...

Best regards,

Manfred. 

by
That makes total sense thanks for pointing out! However I was sure the count of frames starts from 0 which will make it 5 frames in total, so the last frame will always be empty then?
by
Yes, the count starts at 0. This means 0...5 = 6 frames. Each 118x118 pixel requires a bitmap with 118x708 pixels.
by
To me that seems to be a bug then. The project above is iterating frames using NoOfFrames on the Bitmap resource and it returns 5 with the last frame being empty. I think NoOfFrames should either return 4 or the fifth frame should be filled with remaining part of bitmap.
by

The number of frames within your bitmap is 5 - because 707 divided by 118 is 5.99. This means, the bitmap contains five complete frames. Thus, NoOfFrames is 5.

That means, you can select 

Image.FrameNumber = 0;
Image.FrameNumber = 1;
Image.FrameNumber = 2;
Image.FrameNumber = 3;
Image.FrameNumber = 4;

In your code, there is the error that you increment the frame number after you check for the valid range:

if(Variable < Application::menu_icons.NoOfFrames)
{
  Variable++;
}
else
{
  Variable = 0;
}
Image.FrameNumber = Variable;

After changing the code to the following, it works as expected:

Variable++;
if ( Variable >= Application::menu_icons.NoOfFrames )
  Variable = 0;
Image.FrameNumber = Variable;

Best regards,

Manfred.

by
thanks for the generous explanation, I've got my mistake now!

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...