cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to modify the function “void Image::setBitmap(const Bitmap& bmp)�??

LTing
Associate II

​Is it possible to modify the function “void Image::setBitmap(const Bitmap& bmp)�??

I tried to modify this function in the file "\framework\source\touchgfx\widgets\Image.cpp", but the code I modified is useless. Even if I remove this function from Image.cpp, the project can still be successfully built.

8 REPLIES 8
Martin KJELDSEN
Chief III

Hi,

What do you mean by "but the code I modified is useless."? The code is open source to you, so what you're editing is what's getting compiled and linked into your application.

Why would you modify this file? Just trying to understand your motivation 🙂

/Martin

Hi Martin,

Sorry I did not express the problem clearly.

What puzzles me is:​ I modified the code as below, all images still display normally. So I think may be there is an same class and same function(setBitmap) in the touchgfx lib, the function in touchgfx lib is the one that is actually available.

0690X00000AQz9VQAT.png

The reason I am modifying the code is hard to say clearly. Due to insufficient RAM, I have to store the image data in Norflash. I tried to redefine LOCATION_EXTFLASH_ATTRIBUTE, but the hardware does not support this feature. Therefore, in order to display the image, I must first cache the bitmap into RAM and then display it using the function "dynamicBitmapCreate". There are hundreds of images, I don't want to modify them one by one. If I can modify the function "setBitmap", I can easily modify the display method of all the images.

That makes sense. Is Image.cpp even a part of your project? Maybe you're editing it, but it's not getting compiled.

/Martin

Hi Martin,

I am sure Image.cpp has been compiled into my project. In order to prove this, I deliberately removed a ";" in the function setBitmap, such as change "bitmap = bmp;" to "bitmap = bmp", the compiler will prompt for an error, and the project can not be successfully built.

But the strange thing is, even if I remove this function from Image.cpp, or remove the file Image.cpp, the project can still be successfully built.

So I strongly doubt that there is an same class and same function(setBitmap) in the touchgfx lib, and the function in touchgfx lib is the one that is actually available.

It can still be built because the symbols are available in the library. Didn't you just prove your own point, or am i confused?

Can you now do what you want inside the provided .cpp file?

/Martin

I am sorry that my English is not very good. I don't quite understand what you mean.

I'm still can not do what I want inside the provided .cpp file.

That's quite allright. Let me rephrase.

You proved earlier that, when you edited the .cpp file, you could get the compiler to report an error. This means that the code will be linked into your application.

You now say that you still cannot do what you want - So maybe the code you're writing is wrong?

/Martin

The code I edited is not wrong, it can be built successfully.

I added a log, but this log is not output when the project is running.

void Image::setBitmap(const Bitmap& bmp)
{
    printf("Enter the setBitmap function. \n");
    bitmap = bmp;
    // When setting bitmap, adjust size of this widget to match.
    setWidth(bitmap.getWidth());
    setHeight(bitmap.getHeight());
 
    // This bool is no longer used, but maintained for backwards compat.
    hasTransparentPixels = bitmap.hasTransparentPixels();
}

And I remove all code from this function, ​all images still display normally.

void Image::setBitmap(const Bitmap& bmp)
{
 
}

So I think the only possibility is that this function has not been called. And the strange thing is, this function is indeed linked to my app.