/*****************************************************************************/ /* Allocate bitmap for specified dimensions, checking for int overflow */ staticchar *
alloc_bitmap_data(int width, int height, int Bpp)
{ char *result = NULL; if (width > 0 && height > 0 && Bpp > 0)
{ int len = width; /* g_malloc() currently takes an 'int' size */ if (len < INT_MAX / height)
{
len *= height; if (len < INT_MAX / Bpp)
{
len *= Bpp;
result = (char *)malloc(len);
}
}
}
return result;
}
/*****************************************************************************/ struct xrdp_bitmap *
xrdp_bitmap_create(int width, int height, int bpp, int type, struct xrdp_wm *wm)
{ struct xrdp_bitmap *self = (struct xrdp_bitmap *)NULL; int Bpp = 0;
self = (struct xrdp_bitmap *)g_malloc(sizeof(struct xrdp_bitmap), 1); if (self == NULL)
{
LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_create: no memory"); return self;
}
/*****************************************************************************/ void
xrdp_bitmap_delete(struct xrdp_bitmap *self)
{ int i = 0; struct xrdp_mod_data *mod_data = (struct xrdp_mod_data *)NULL;
if (self == 0)
{ return;
}
if (self->wm != 0)
{ if (self->wm->focused_window != 0)
{ if (self->wm->focused_window->focused_control == self)
{
self->wm->focused_window->focused_control = 0;
}
}
if (self->wm->focused_window == self)
{
self->wm->focused_window = 0;
}
if (self->wm->dragging_window == self)
{
self->wm->dragging_window = 0;
}
if (self->wm->button_down == self)
{
self->wm->button_down = 0;
}
if (self->wm->popup_wnd == self)
{
self->wm->popup_wnd = 0;
}
if (self->wm->login_window == self)
{
self->wm->login_window = 0;
}
if (self->wm->log_wnd == self)
{
self->wm->log_wnd = 0;
}
}
if (self->child_list != 0)
{ for (i = self->child_list->count - 1; i >= 0; i--)
{
xrdp_bitmap_delete((struct xrdp_bitmap *)self->child_list->items[i]);
}
list_delete(self->child_list);
}
if (self->parent != 0)
{
i = list_index_of(self->parent->child_list, (long)self);
if (i >= 0)
{
list_remove_item(self->parent->child_list, i);
}
}
if (self->string_list != 0) /* for combo */
{
list_delete(self->string_list);
}
if (self->data_list != 0) /* for combo */
{ for (i = 0; i < self->data_list->count; i++)
{
mod_data = (struct xrdp_mod_data *)list_get_item(self->data_list, i);
if (mod_data != 0)
{
list_delete(mod_data->names);
list_delete(mod_data->values);
}
}
list_delete(self->data_list);
}
if (!self->do_not_free_data)
{
g_free(self->data);
}
g_free(self->caption1);
g_free(self);
}
/*****************************************************************************/ /* returns error */ int
xrdp_bitmap_resize(struct xrdp_bitmap *self, int width, int height)
{ int Bpp = 0;
/*****************************************************************************/ int
xrdp_bitmap_get_pixel(struct xrdp_bitmap *self, int x, int y)
{ if (self == 0)
{ return0;
}
if (self->data == 0)
{ return0;
}
if (x >= 0 && x < self->width && y >= 0 && y < self->height)
{ if (self->bpp == 8)
{ return GETPIXEL8(self->data, x, y, self->width);
} elseif (self->bpp == 15 || self->bpp == 16)
{ return GETPIXEL16(self->data, x, y, self->width);
} elseif (self->bpp >= 24)
{ return GETPIXEL32(self->data, x, y, self->width);
}
}
return0;
}
/*****************************************************************************/ int
xrdp_bitmap_set_pixel(struct xrdp_bitmap *self, int x, int y, int pixel)
{ if (self == 0)
{ return0;
}
if (self->data == 0)
{ return0;
}
if (x >= 0 && x < self->width && y >= 0 && y < self->height)
{ if (self->bpp == 8)
{
SETPIXEL8(self->data, x, y, self->width, pixel);
} elseif (self->bpp == 15 || self->bpp == 16)
{
SETPIXEL16(self->data, x, y, self->width, pixel);
} elseif (self->bpp >= 24)
{
SETPIXEL32(self->data, x, y, self->width, pixel);
}
}
return0;
}
/*****************************************************************************/ /* copy part of self at x, y to 0, 0 in dest */ /* returns error */ int
xrdp_bitmap_copy_box(struct xrdp_bitmap *self, struct xrdp_bitmap *dest, int x, int y, int cx, int cy)
{ int i; int destx; int desty; int incs; int incd;
tui8 *s8;
tui8 *d8;
tui16 *s16;
tui16 *d16;
tui32 *s32;
tui32 *d32;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.