Within one of our MDL applications, we want to draw a logo on a dialog. This logo is stored in an external PNG file with transparent background.
The logo is loaded by means of mdlImage_readFileToRGB(), resized by means of mdlImage_resize() and drawn with mdlWindow_rgbDataDraw().
Everything works great except for the background: it's black instead of transparent.
Any idea how to get a transparent background?
We use MSCE version 10.16 and corresponding SDK.
Hi Robert Kock,
Are both the Input image data buffer and Output Format parameter RGBA? e.g. Calling mdlWindow_rgbDataDraw using either: TRUECOLOR_RGBA or IMAGEFORMAT_RGBA
If you suspect the output format is correctly being set, you may want to see this previous post on black background color being used for alpha channels.You may also consider using an alternate method (mdlWindow_transparentRgbDataDraw) that permits you to provide your own transparentRgbP value and possibly help validate being able to display your RGBA to a target mdlWindow API dialog/window correctly (too):
Mstn\MdlApi\msimage.fdf:421:int mdlWindow_transparentRgbDataDraw
HTH,Bob
Answer Verified By: Robert Kock
Hi Robert,
I tried the options TRUECOLOR_RGBA and IMAGEFORMAT_RGBA but they give me very strange results: the image is scaled and duplicated.
The function mdlWindow_transparentRgbDataDraw resolved the problem if I specify BLACK as the transparent value.
In order to obtain my black-RGB, I call the following functions:
BSIColorPalette* palette;BSIColorDescr* color;RgbColorDef black;mdlColorPal_create(&palette, 1);color = mdlColorPal_getColorDescr(palette, 0);mdlColorDescr_setByColorId(color, BLACK_INDEX, FALSE);mdlColorDescr_getRgb(&black, color);
Can this be done in an easier way?
Thanks,
Robert
You could directly set an RgbColorDef instance (DgnPlatform\DgnPlatform.r.h+340) a preferred color similar to this:
RGBColorDef transparentColor = {255,255,255};
Thank you so much
You're welcome.