On 24/01/2013 at 14:28, xxxxxxxx wrote:
User Information:
Cinema 4D Version:
Platform:
Language(s) :
---------
I can't get the following code to work properly. I want to draw a green line at the bottom line of the
ObjectDatas' icon when some condition is true. I've tried using BaseBitmap::SetPixel(), but it didn't
work with images having an alpha-channel. Using BaseBitmap::GetInternalChannel() in combination
with BaseBitmap::SetAlphaPixel() didn't work either. Possibly because of missing documentation or
example code, or my stupidness.
Therefore, I'm using a GeClipMap. But the drawn line is not visible at all (even with images without
an alpha-channel). What am I doing wrong here?
void OnGetCustomIcon(BaseObject* op, GetCustomIconData* data) {
IconData* dIcon = data->dat;
if (customIcon) {
dIcon->x = 0;
dIcon->y = 0;
dIcon->w = customIcon->GetBw();
dIcon->h = customIcon->GetBh();
dIcon->bmp = customIcon;
data->filled = TRUE;
}
else {
** // Could the memory leak be located here?**
GetIcon(Ocontainer, dIcon); // Load the default bitmap of the plugin.
if (dIcon->bmp) {
BaseBitmap* clone = dIcon->bmp->GetClone();
/* We do *not* free the bitmap in dIcon->bmp because it is
* references by the iconlib. */
dIcon->bmp = clone;
}
}
if (dIcon->bmp) {
/* Draw colored lines into the bitmap to display that
* objects or tags are hidden. */
GeClipMap* map = GeClipMap::Alloc();
map->Init(dIcon->bmp);
map->BeginDraw();
map->SetColor(167, 255, 36, 255);
LONG width = dIcon->bmp->GetBw();
LONG height = dIcon->bmp->GetBh();
if (conditionForHorizontalLineAtTheBottom) {
for (LONG i=0; i < width; i++) {
map->SetPixel(i, height - 1);
}
}
if (conditionForVerticalLineOnTheRight) {
for (LONG i=0; i < height; i++) {
map->SetPixel(i, width - 1);
}
}
** // No changes.**
map->EndDraw();
BaseBitmap* bmp = map->GetBitmap();
if (bmp != dIcon->bmp) {
BaseBitmap::Free(dIcon->bmp);
dIcon->bmp = bmp;
}
GeClipMap::Free(map);
}
data->filled = TRUE;
}
Ideas?
Thanks in advance,
Niklas