Jump to content

Reading 1px of bmp


MobileWill

Recommended Posts

Is there away to only load a certain pixel from a bmp? I am working on improving graphing performance while at the same time increasing the visual quality. I have a way to do it but I need a way to read back 1 pixel of a bmp of the graph background. Right now I just create an array of HTML color hex values but seems like there should be a better way to use some builtin function. I made the array myself. I haven't found a converter from BMP to C HTML Hex color array. 

 

Thanks. 

Link to comment
Share on other sites

Reading just one specific pixel is not possible as the image gets decoded on the fly. Even if the image is cached the cache is specific to each image so we don't provide any API to access that.
There are two workarounds to this:

  1. Use the native format to store your picture. As the native format is uncompressed by definition it's possible to access any pixel at any time. However, we don't provide an API for that, you'd have to write that yourself. Also note that this can be horribly slow depending on where your image is located and so on. After all, the main reason to use a native image format is that it doesn't need to be cached.
  2. The better approach would be to take your regular image, render it into a pixmap and then access the pixels from that pixmap. The pixmaps provide API to get direct access to each pixel. This would probably be the best solution.

 

Regarding your second post:

  1. The studio allows you to specify files that get included in the generated romfs_files.h in the settings. You can specify your path to the BMP there. However, the studio won't open the image for you. We should probably think of introducing a resource manager for the next release where every resource (font, image, widget style, ...) is located in a central place. Please feel free to leave your suggestions in the corresponding uGFX-Studio forum.
  2. Yes, containers can have image backgrounds. You will find all about that in the API documentation: http://api.ugfx.org/group___renderings___container.html
  3. Labels don't have a transparent background rendering routine for several reasons which have been discussed before: 

 

Link to comment
Share on other sites

If you are not planning on changing the text on a label at runtime you can also write your own custom redraw routine for the label in order to get transparency. It would be a simplified version of the standard default draw routine.

The issues with a transparent label primarily relate to redraw issues if the text changes or the label is moved. If in your application the text doesn't change and the label doesn't move relative to its container then a transparent label makes some sense.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...