This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GrImageDraw - Drawing images with the background transparent

Hi,

I am trying to display images using GrImageDraw. But I am not able to blend the background image to the LCD screen. Is there a way to draw images with option to make the background  of the image as transparent, so that the image blends in with the LCD screen background

Regards,

Rashmi

  • Rashmi Naik said:
    Is there a way to draw images with option to make the background  of the image ... transparent

    How do you - or importantly your program - separate "foreground" from the background?    Might that determination be critical to your attack?

    My firm has not used vendor's graphic lib. - I can tell you that more classic graphic methods - which accomplish your goal (& multiple others - btw) usually "build the screen" image from an assortment of well defined (i.e. segregated) graphic "planes" - which may be (selectively) "logically combined" so that they appear (on screen) to your liking.  

    Such methods demand (and eat) memory - which is a rather limited commodity - with most such MCUs.   The screen's size (in pixels) and color depth determine the size of memory required.   (most always (far) exceeding the SRAM capacity of these MCUs)

    On a smaller scale (either w/a pixel-limited display [perhaps 160x128 or so] or w/in a similar, confined pixel area on a larger screen) you may experiment with the process of:

    a) separating the forground from the background of your image

    b) post separation - placing each image in distinct memory locations

    c) logically combining the two (via "or, and, etc.") with each other - AND  with the "other" (often pre-existing) screen content.  (i.e. your "graphic" is being "superimposed" upon the existing screen

    More powerful ARM MCUs (as on cells, tablets) address vast memory - and enjoy HW mechanisms which speed & simplify this process.

    Can you do this here?   Perhaps - surely on a "limited scale" - but not w/out (I'd expect) some serious time/effort/experimentation (and quite likely, added memory).

  • Hello Rashmi,

    I think I mentioned in the past. The GrTransparentImageDraw is better than GrImageDraw as it gives the appearance of "transparency"

    Regards
    Amit
  • Hi Amit,

    I am using an image which is showing white patches as attached . How will using GrTransparentImageDraw  help? This api description says "ui32Transparent is the image color which is to be considered transparent.". How do we use this to let the background colour shine through and not the white patch?

    Thanks,

    Rashmi

  • Hello Rashmi

    Is the image coming from a file that has been converted to pnm format for the grlib?

    Regards
    Amit
  • Hi Amit,

    Yes. I have used GIMP for converting jpeg to pnm and pnmtoc tool for converting pnm to c

    Let me know if there are betters tools for this

    Thanks,

    Rashmi

  • Hello Rashmi

    The issue is that for images the background setting will not help. The white pixels are due to the fact that they are part of the pixel, One thing that you can try to do is to change the information in the original image to match the background color

    Regards
    Amit