예제 #1
0
int iupdrvImageGetRawInfo(void* handle, int *w, int *h, int *bpp, iupColor* colors, int *colors_count)
{
  /* How to get the pallete? */
  (void)colors;
  (void)colors_count;
  return iupdrvImageGetInfo(handle, w, h, bpp);
}
예제 #2
0
static int winDialogSetOpacityImageAttrib(Ihandle *ih, const char *value)
{
  HBITMAP hBitmap = (HBITMAP)iupImageGetImage(value, ih, 0);
  if (!hBitmap)
    return 0;
  else
  {
    BLENDFUNCTION blend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
    POINT ptSrc = { 0, 0 };

    HDC hDC = GetDC(NULL);
    HDC hMemDC = CreateCompatibleDC(hDC);
    HBITMAP oldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
    int img_w, img_h, bpp;
    SIZE size;

    iupdrvImageGetInfo(hBitmap, &img_w, &img_h, &bpp);
    size.cx = img_w;
    size.cy = img_h;

    UpdateLayeredWindow(ih->handle, hDC, NULL, &size, hMemDC, &ptSrc, RGB(0, 0, 0), &blend, ULW_ALPHA);

    SelectObject(hMemDC, oldBitmap);
    DeleteDC(hMemDC);
    ReleaseDC(NULL, hDC);

    return 1;
  }
}
예제 #3
0
static int iTabsGetMaxWidth(Ihandle* ih)
{
  int max_width = 0, width, pos;
  char *tabtitle, *tabimage;
  Ihandle* child;

  for (pos = 0, child = ih->firstchild; child; child = child->brother, pos++)
  {
    tabtitle = iupAttribGet(child, "TABTITLE");
    if (!tabtitle) tabtitle = iupTabsAttribGetStrId(ih, "TABTITLE", pos);
    tabimage = iupAttribGet(child, "TABIMAGE");
    if (!tabimage) tabimage = iupTabsAttribGetStrId(ih, "TABIMAGE", pos);
    if (!tabtitle && !tabimage)
      tabtitle = "     ";

    width = 0;
    if (tabtitle)
      width += iupdrvFontGetStringWidth(ih, tabtitle);

    if (tabimage)
    {
      void* img = iupImageGetImage(tabimage, ih, 0);
      if (img)
      {
        int w;
        iupdrvImageGetInfo(img, &w, NULL, NULL);
        width += w;
      }
    }

    if (width > max_width) max_width = width;
  }

  return max_width;
}
예제 #4
0
void iupdrvImageGetData(void* handle, unsigned char* imgdata)
{
  Pixmap pixmap = (Pixmap)handle;
  int w, h, y, x, bpp;
  XImage *xi;

  if (!iupdrvImageGetInfo(handle, &w, &h, &bpp))
    return;

  if (bpp == 8)
    return;

  xi = XGetImage(iupmot_display, pixmap, 0, 0, w, h, ULONG_MAX, ZPixmap);
  if (xi)
  {
    /* planes are packed and top-bottom in this imgdata */
    int planesize = w*h;
    unsigned char *line_data;

    for (y = 0; y<h; y++)
    {
      line_data = imgdata + y * planesize;
      for (x = 0; x<w; x++)
      {
        iupmotColorGetRGB(XGetPixel(xi, x, y), line_data + x, line_data + x + 1, line_data + x + 2);
      }
    }

    XDestroyImage(xi);
  }
}
예제 #5
0
static int iTabsGetMaxHeight(Ihandle* ih)
{
  int max_height = 0, h, pos;
  char *tabimage;
  Ihandle* child;

  for (pos = 0, child = ih->firstchild; child; child = child->brother, pos++)
  {
    tabimage = iupAttribGet(child, "TABIMAGE");
    if (!tabimage) tabimage = iupTabsAttribGetStrId(ih, "TABIMAGE", pos);

    if (tabimage)
    {
      void* img = iupImageGetImage(tabimage, ih, 0);
      if (img)
      {
        iupdrvImageGetInfo(img, NULL, &h, NULL);
        if (h > max_height) max_height = h;
      }
    }
  }

  iupdrvFontGetCharSize(ih, NULL, &h);
  if (h > max_height) max_height = h;

  return max_height;
}
예제 #6
0
void iupdrvImageGetRawData(void* handle, unsigned char* imgdata)
{
  Pixmap pixmap = (Pixmap)handle;
  int w, h, y, x, bpp;
  XImage *xi;

  if (!iupdrvImageGetInfo(handle, &w, &h, &bpp))
    return;

  if (bpp==8)
    return;

  xi = XGetImage(iupmot_display, pixmap, 0, 0, w, h, ULONG_MAX, ZPixmap);
  if (xi)
  {
    /* planes are separated in imgdata */
    int planesize = w*h;
    unsigned char *r = imgdata,
                  *g = imgdata+planesize,
                  *b = imgdata+2*planesize;
    for (y=0; y<h; y++)
    {
      int lineoffset = (h-1 - y)*w;  /* imgdata is bottom up */
      for (x=0; x<w; x++)
      {
        iupmotColorGetRGB(XGetPixel(xi, x, y), r + lineoffset+x, g + lineoffset+x, b + lineoffset+x);
      }
    }
    
    XDestroyImage(xi);
  }
}
예제 #7
0
void iupImageGetInfo(const char* name, int *w, int *h, int *bpp)
{
  void* image;
  Ihandle *ih;

  if (!name)
    return;

  /* Check first in the system resources. */
  image = iupdrvImageLoad(name, IUPIMAGE_IMAGE);
  if (image)
  {
    iupdrvImageGetInfo(image, w, h, bpp);
    return;
  }

  /* get handle from name */
  ih = IupGetHandle(name);
  if (!ih)
  {
    /* Check in the stock images. */
    const char* native_name = NULL;
    iImageStockGet(name, &ih, &native_name);

    if (native_name) 
    {
      image = iupdrvImageLoad(native_name, IUPIMAGE_IMAGE);
      if (image) 
      {
        iupdrvImageGetInfo(image, w, h, bpp);
        return;
      }
    }

    if (!ih)
      return;
  }

  if (w) *w = ih->currentwidth;
  if (h) *h = ih->currentheight;
  if (bpp) *bpp = IupGetInt(ih, "BPP");
}
예제 #8
0
void iupDrawImage(IdrawCanvas* dc, const char* name, int make_inactive, int x, int y, int *img_w, int *img_h)
{
    int bpp;
    Pixmap pixmap = (Pixmap)iupImageGetImage(name, dc->ih, make_inactive);
    if (!pixmap)
        return;

    /* must use this info, since image can be a driver image loaded from resources */
    iupdrvImageGetInfo((void*)pixmap, img_w, img_h, &bpp);

    XCopyArea(iupmot_display, pixmap, dc->pixmap, dc->pixmap_gc, 0, 0, *img_w, *img_h, x, y);
}
예제 #9
0
파일: iupgtk_draw.c 프로젝트: LuaDist/iup
void iupDrawImage(IdrawCanvas* dc, const char* name, int make_inactive, int x, int y, int *img_w, int *img_h)
{
  int bpp;
  GdkPixbuf* pixbuf = iupImageGetImage(name, dc->ih, make_inactive);
  if (!pixbuf)
    return;

  /* must use this info, since image can be a driver image loaded from resources */
  iupdrvImageGetInfo(pixbuf, img_w, img_h, &bpp);

  gdk_draw_pixbuf(dc->pixmap, dc->pixmap_gc, pixbuf, 0, 0, x, y, *img_w, *img_h, GDK_RGB_DITHER_NORMAL, 0, 0);
}
예제 #10
0
static void winLabelDrawImage(Ihandle* ih, HDC hDC, int rect_width, int rect_height)
{
  int xpad = ih->data->horiz_padding, 
      ypad = ih->data->vert_padding;
  int x, y, width, height, bpp;
  HBITMAP hBitmap, hMask = NULL;
  char *name;
  int make_inactive = 0;

  if (iupdrvIsActive(ih))
    name = iupAttribGet(ih, "IMAGE");
  else
  {
    name = iupAttribGet(ih, "IMINACTIVE");
    if (!name)
    {
      name = iupAttribGet(ih, "IMAGE");
      make_inactive = 1;
    }
  }

  hBitmap = iupImageGetImage(name, ih, make_inactive);
  if (!hBitmap)
    return;

  /* must use this info, since image can be a driver image loaded from resources */
  iupdrvImageGetInfo(hBitmap, &width, &height, &bpp);

  if (ih->data->horiz_alignment == IUP_ALIGN_ARIGHT)
    x = rect_width - (width + 2*xpad);
  else if (ih->data->horiz_alignment == IUP_ALIGN_ACENTER)
    x = (rect_width - (width + 2*xpad))/2;
  else  /* ALEFT */
    x = 0;

  if (ih->data->vert_alignment == IUP_ALIGN_ABOTTOM)
    y = rect_height - (height + 2*ypad);
  else if (ih->data->vert_alignment == IUP_ALIGN_ATOP)
    y = 0;
  else  /* ACENTER */
    y = (rect_height - (height + 2*ypad))/2;

  x += xpad;
  y += ypad;

  if (bpp == 8)
    hMask = iupdrvImageCreateMask(IupGetHandle(name));

  iupwinDrawBitmap(hDC, hBitmap, hMask, x, y, width, height, bpp);

  if (hMask)
    DeleteObject(hMask);
}
예제 #11
0
void iupdrvDrawImage(IdrawCanvas* dc, const char* name, int make_inactive, const char* bgcolor, int x, int y, int w, int h)
{
  int bpp, img_w, img_h;
  GdkPixbuf* pixbuf = iupImageGetImage(name, dc->ih, make_inactive, bgcolor);
  if (!pixbuf)
    return;

  /* must use this info, since image can be a driver image loaded from resources */
  iupdrvImageGetInfo(pixbuf, &img_w, &img_h, &bpp);

  gdk_draw_pixbuf(dc->pixmap, dc->pixmap_gc, pixbuf, 0, 0, x, y, img_w, img_h, GDK_RGB_DITHER_NORMAL, 0, 0);

  /* zoom not supported */
  (void)w;
  (void)h;
}
예제 #12
0
파일: iupwin_list.c 프로젝트: LuaDist/iup
static int winListSetSpacingAttrib(Ihandle* ih, const char* value)
{
  if (ih->data->is_dropdown)
    return 0;

  if (!iupStrToInt(value, &ih->data->spacing))
    ih->data->spacing = 0;

  if (ih->handle)
  {
    int txt_h;
    iupdrvFontGetCharSize(ih, NULL, &txt_h);
    txt_h += 2*ih->data->spacing;

    /* set for all items */
    if (!ih->data->show_image)
      SendMessage(ih->handle, WIN_SETITEMHEIGHT(ih), 0, txt_h);
    else
    {
      /* must manually set for each item */
      int img_h, i, count = SendMessage(ih->handle, WIN_GETCOUNT(ih), 0, 0);

      for (i=0; i<count; i++)
      { 
        winListItemData* itemdata = winListGetItemData(ih, i);
        if (itemdata->hBitmap)
        {
          iupdrvImageGetInfo(itemdata->hBitmap, NULL, &img_h, NULL);
          img_h += 2*ih->data->spacing;

          if (img_h > txt_h)
            SendMessage(ih->handle, WIN_SETITEMHEIGHT(ih), i, img_h);
          else
            SendMessage(ih->handle, WIN_SETITEMHEIGHT(ih), i, txt_h);
        }
        else
          SendMessage(ih->handle, WIN_SETITEMHEIGHT(ih), i, txt_h);
      }
    }
    return 0;
  }
  else
    return 1; /* store until not mapped, when mapped will be set again */
}
예제 #13
0
void iupDrawImage(IdrawCanvas* dc, const char* name, int make_inactive, int x, int y, int *img_w, int *img_h)
{
  int bpp;
  HBITMAP hMask = NULL;
  HBITMAP hBitmap = (HBITMAP)iupImageGetImage(name, dc->ih, make_inactive);
  if (!hBitmap)
    return;

  /* must use this info, since image can be a driver image loaded from resources */
  iupdrvImageGetInfo(hBitmap, img_w, img_h, &bpp);

  if (bpp == 8)
    hMask = iupdrvImageCreateMask(IupGetHandle(name));

  iupwinDrawBitmap(dc->hBitmapDC, hBitmap, hMask, x, y, *img_w, *img_h, bpp);

  if (hMask)
    DeleteObject(hMask);
}
예제 #14
0
void iupDrawImage(IdrawCanvas* dc, const char* name, int make_inactive, int x, int y, int *img_w, int *img_h)
{
  int bpp;
  GdkPixbuf* pixbuf = iupImageGetImage(name, dc->ih, make_inactive);
  if (!pixbuf)
    return;

  /* must use this info, since image can be a driver image loaded from resources */
  iupdrvImageGetInfo(pixbuf, img_w, img_h, &bpp);

  cairo_save (dc->image_cr);

  cairo_rectangle(dc->image_cr, x, y, *img_w, *img_h);
  cairo_clip(dc->image_cr);

  gdk_cairo_set_source_pixbuf(dc->image_cr, pixbuf, x, y);
  cairo_paint(dc->image_cr);  /* paints the current source everywhere within the current clip region. */

  /* must restore clipping */
  cairo_restore (dc->image_cr);
}
예제 #15
0
파일: iup_list.c 프로젝트: Vulcanior/IUP
static void iListGetItemImageInfo(Ihandle *ih, int id, int *img_w, int *img_h)
{
  *img_w = 0;
  *img_h = 0;

  if (!ih->handle)
  {
    char *value = iupAttribGetId(ih, "IMAGE", id);
    if (value)
      iupImageGetInfo(value, img_w, img_h, NULL);
  }
  else
  {
    void* handle = iupdrvListGetImageHandle(ih, id);
    if (handle)
    {
      int bpp;
      iupdrvImageGetInfo(handle, img_w, img_h, &bpp);
    }
  }
}
예제 #16
0
void iupdrvImageGetRawData(void* handle, unsigned char* imgdata)
{
  GdkPixbuf* pixbuf = (GdkPixbuf*)handle;
  int w, h, y, x, bpp;
  guchar *pixdata, *pixline_data;
  int rowstride, channels, planesize;
  unsigned char *r, *g, *b, *a;

  if (!iupdrvImageGetInfo(handle, &w, &h, &bpp))
    return;

  if (bpp==8)
    return;

  pixdata = gdk_pixbuf_get_pixels(pixbuf);
  rowstride = gdk_pixbuf_get_rowstride(pixbuf);
  channels = gdk_pixbuf_get_n_channels(pixbuf);

  /* planes are separated in imgdata */
  planesize = w*h;
  r = imgdata;
  g = imgdata+planesize;
  b = imgdata+2*planesize;
  a = imgdata+3*planesize;
  for (y=0; y<h; y++)
  {
    int lineoffset = (h-1 - y)*w;  /* imgdata is bottom up */
    pixline_data = pixdata + y * rowstride;
    for(x=0;x<w;x++)
    {
      int pos = x*channels;
      r[lineoffset+x] = pixline_data[pos];
      g[lineoffset+x] = pixline_data[pos+1];
      b[lineoffset+x] = pixline_data[pos+2];

      if (bpp == 32)
        a[lineoffset+x] = pixline_data[pos+3];
    }
  }
}
예제 #17
0
파일: iupwin_button.c 프로젝트: defdef/iup
static HBITMAP winButtonGetBitmap(Ihandle* ih, UINT itemState, int *shift, int *w, int *h, int *bpp, HBITMAP *hMask)
{
  char *name;
  int make_inactive = 0;
  HBITMAP hBitmap;
  *hMask = NULL;

  if (itemState & ODS_DISABLED)
  {
    name = iupAttribGet(ih, "IMINACTIVE");
    if (!name)
    {
      name = iupAttribGet(ih, "IMAGE");
      make_inactive = 1;
    }
  }
  else
  {
    name = iupAttribGet(ih, "IMPRESS");
    if (itemState & ODS_SELECTED && name)
    {
      if (shift && !iupAttribGetBoolean(ih, "IMPRESSBORDER")) 
        *shift = 0;
    }
    else
      name = iupAttribGet(ih, "IMAGE");
  }

  hBitmap = iupImageGetImage(name, ih, make_inactive);

  /* must use this info, since image can be a driver image loaded from resources */
  iupdrvImageGetInfo(hBitmap, w, h, bpp);

  if (*bpp == 8)
    *hMask = iupdrvImageCreateMask(IupGetHandle(name));

  return hBitmap;
}
예제 #18
0
void iupImageStockLoad(const char *name)
{
  const char* native_name = NULL;
  Ihandle* ih = NULL;
  iImageStockGet(name, &ih, &native_name);
  if (ih)
    IupSetHandle(name, ih);
  else if (native_name)
  {
    /* dummy image to save the GTK stock name */
    void* image = iupdrvImageLoad(native_name, IUPIMAGE_IMAGE);
    if (image)
    {
      int w, h, bpp;
      iupdrvImageGetInfo(image, &w, &h, &bpp);
      if (bpp == 32)
        ih = IupImageRGBA(w,h,NULL);
      else
        ih = IupImageRGB(w,h,NULL);
      IupSetHandle(native_name, ih);
    }
  }
}
예제 #19
0
파일: iupwin_list.c 프로젝트: LuaDist/iup
static int winListSetImageAttrib(Ihandle* ih, int id, const char* value)
{
  winListItemData* itemdata;
  HBITMAP hBitmap = iupImageGetImage(value, ih, 0);
  int pos = iupListGetPos(ih, id);

  if (!ih->data->show_image || pos < 0)
    return 0;

  itemdata = winListGetItemData(ih, pos);
  itemdata->hBitmap = hBitmap;

  if (itemdata->hBitmap)
  {
    int txt_h, img_w, img_h;
    iupdrvFontGetCharSize(ih, NULL, &txt_h);
    iupdrvImageGetInfo(itemdata->hBitmap, &img_w, &img_h, NULL);

    if (img_h > txt_h)
    {
      if (ih->data->is_dropdown && !ih->data->has_editbox && img_h >= ih->data->maximg_h)
        SendMessage(ih->handle, WIN_SETITEMHEIGHT(ih), (WPARAM)-1, img_h);  /* set also for the selection box */

      if (!ih->data->is_dropdown)
        img_h += 2*ih->data->spacing;
      SendMessage(ih->handle, WIN_SETITEMHEIGHT(ih), pos, img_h);
    }

    if (img_w > ih->data->maximg_w)
      ih->data->maximg_w = img_w;
    if (img_h > ih->data->maximg_h)
      ih->data->maximg_h = img_h;
  }

  return 1;
}
예제 #20
0
static int winTabsGetImageIndex(Ihandle* ih, const char* name)
{
  HIMAGELIST image_list;
  int count, i, bpp, ret;
  Iarray* bmp_array;
  HBITMAP *bmp_array_data, hMask=NULL;
  HBITMAP bmp = iupImageGetImage(name, ih, 0);
  if (!bmp)
    return -1;

  /* the array is used to avoi adding the same bitmap twice */
  bmp_array = (Iarray*)iupAttribGet(ih, "_IUPWIN_BMPARRAY");
  if (!bmp_array)
  {
    /* create the array if does not exist */
    bmp_array = iupArrayCreate(50, sizeof(HBITMAP));
    iupAttribSetStr(ih, "_IUPWIN_BMPARRAY", (char*)bmp_array);
  }

  bmp_array_data = iupArrayGetData(bmp_array);

  image_list = (HIMAGELIST)SendMessage(ih->handle, TCM_GETIMAGELIST, 0, 0);
  if (!image_list)
  {
    int width, height;
    UINT flags = ILC_COLOR32|ILC_MASK;

    /* must use this info, since image can be a driver image loaded from resources */
    iupdrvImageGetInfo(bmp, &width, &height, &bpp);

    /* create the image list if does not exist */
    image_list = ImageList_Create(width, height, flags, 0, 50);
    SendMessage(ih->handle, TCM_SETIMAGELIST, 0, (LPARAM)image_list);
  }
  else
    iupdrvImageGetInfo(bmp, NULL, NULL, &bpp);

  /* check if that bitmap is already added to the list,
     but we can not compare with the actual bitmap at the list since it is a copy */
  count = ImageList_GetImageCount(image_list);
  for (i=0; i<count; i++)
  {
    if (bmp_array_data[i] == bmp)
      return i;
  }

  if (bpp == 8)
  {
    Ihandle* image = IupGetHandle(name);
    if (image)
    {
      iupAttribSetStr(image, "_IUPIMG_NO_INVERT", "1");
      hMask = iupdrvImageCreateMask(image);
      iupAttribSetStr(image, "_IUPIMG_NO_INVERT", NULL);
    }
  }

  bmp_array_data = iupArrayInc(bmp_array);
  bmp_array_data[i] = bmp;
  ret = ImageList_Add(image_list, bmp, hMask);  /* the bmp is duplicated at the list */
  DeleteObject(hMask);
  return ret;
}
예제 #21
0
파일: iupwin_list.c 프로젝트: LuaDist/iup
static void winListDrawItem(Ihandle* ih, DRAWITEMSTRUCT *drawitem)
{
  char* text;
  int txt_w, txt_h;
  winListItemData* itemdata;
  HFONT hFont = (HFONT)iupwinGetHFontAttrib(ih);
  iupwinBitmapDC bmpDC;
  HDC hDC;
  RECT rect;
  COLORREF fgcolor, bgcolor;

  int x = drawitem->rcItem.left;
  int y = drawitem->rcItem.top;
  int width = drawitem->rcItem.right - drawitem->rcItem.left;
  int height = drawitem->rcItem.bottom - drawitem->rcItem.top;

  /* If there are no list box items, skip this message */
  if (drawitem->itemID == -1)
    return;

  hDC = iupwinDrawCreateBitmapDC(&bmpDC, drawitem->hDC, x, y, width, height);

  if (drawitem->itemState & ODS_SELECTED)
    bgcolor = GetSysColor(COLOR_HIGHLIGHT);
  else if (!iupwinGetColorRef(ih, "BGCOLOR", &bgcolor))
    bgcolor = GetSysColor(COLOR_WINDOW);
  SetDCBrushColor(hDC, bgcolor);
  SetRect(&rect, 0, 0, width, height);
  FillRect(hDC, &rect, (HBRUSH)GetStockObject(DC_BRUSH));

  if (iupdrvIsActive(ih))
  {
    if (drawitem->itemState & ODS_SELECTED)
      fgcolor = GetSysColor(COLOR_HIGHLIGHTTEXT);
    else if (!iupwinGetColorRef(ih, "FGCOLOR", &fgcolor))
      fgcolor = GetSysColor(COLOR_WINDOWTEXT);
  }
  else
    fgcolor = GetSysColor(COLOR_GRAYTEXT);

  /* Get the bitmap associated with the item */
  itemdata = winListGetItemData(ih, drawitem->itemID);

  /* Get and draw the string associated with the item */
  text = winListGetText(ih, drawitem->itemID);
  iupdrvFontGetMultiLineStringSize(ih, text, &txt_w, &txt_h);

  x = ih->data->maximg_w + 3; /* spacing between text and image */
  y = (height - txt_h)/2;  /* vertically centered */
  iupwinDrawText(hDC, text, x, y, txt_w, txt_h, hFont, fgcolor, 0);

  /* Draw the bitmap associated with the item */
  if (itemdata->hBitmap)
  {
    int bpp, img_w, img_h;
    HBITMAP hMask = NULL;

    iupdrvImageGetInfo(itemdata->hBitmap, &img_w, &img_h, &bpp);

    if (bpp == 8)
    {
      char name[50];
      sprintf(name, "IMAGE%d", (int)drawitem->itemID+1);
      hMask = iupdrvImageCreateMask(IupGetAttributeHandle(ih, name));
    }

    x = 0;
    y = (height - img_h)/2;  /* vertically centered */
    iupwinDrawBitmap(hDC, itemdata->hBitmap, hMask, x, y, img_w, img_h, bpp);

    if (hMask)
      DeleteObject(hMask);
  }

  /* If the item has the focus, draw the focus rectangle */
  if (drawitem->itemState & ODS_FOCUS)
    iupdrvDrawFocusRect(ih, hDC, 0, 0, width, height);

  free(text);
  iupwinDrawDestroyBitmapDC(&bmpDC);
}
예제 #22
0
static void winToggleDrawImage(Ihandle* ih, HDC hDC, int rect_width, int rect_height, int border, UINT itemState)
{
    /* called only when (ih->data->type==IUP_TOGGLE_IMAGE && (iupwin_comctl32ver6 || ih->data->flat)) */
    int xpad = ih->data->horiz_padding + border,
        ypad = ih->data->vert_padding + border;
    int horiz_alignment, vert_alignment;
    int x, y, width, height, bpp;
    HBITMAP hBitmap, hMask = NULL;
    char *name;
    int make_inactive = 0;

    if (itemState & ODS_DISABLED)
    {
        name = iupAttribGet(ih, "IMINACTIVE");
        if (!name)
        {
            name = iupAttribGet(ih, "IMAGE");
            make_inactive = 1;
        }
    }
    else
    {
        name = iupAttribGet(ih, "IMPRESS");
        if (!(itemState & ODS_SELECTED && name))
            name = iupAttribGet(ih, "IMAGE");
    }

    hBitmap = iupImageGetImage(name, ih, make_inactive);
    if (!hBitmap)
        return;

    /* must use this info, since image can be a driver image loaded from resources */
    iupdrvImageGetInfo(hBitmap, &width, &height, &bpp);

    winToggleGetAlignment(ih, &horiz_alignment, &vert_alignment);
    if (horiz_alignment == IUP_ALIGN_ARIGHT)
        x = rect_width - (width + 2*xpad);
    else if (horiz_alignment == IUP_ALIGN_ACENTER)
        x = (rect_width - (width + 2*xpad))/2;
    else  /* ALEFT */
        x = 0;

    if (vert_alignment == IUP_ALIGN_ABOTTOM)
        y = rect_height - (height + 2*ypad);
    else if (vert_alignment == IUP_ALIGN_ATOP)
        y = 0;
    else  /* ACENTER */
        y = (rect_height - (height + 2*ypad))/2;

    x += xpad;
    y += ypad;

    if (itemState & ODS_SELECTED && !iupwin_comctl32ver6)
    {
        if (iupAttribGet(ih, "_IUPWIN_PRESSED"))
        {
            x++;
            y++;
            iupAttribSet(ih, "_IUPWIN_PRESSED", NULL);
        }
    }

    if (bpp == 8)
        hMask = iupdrvImageCreateMask(IupGetHandle(name));

    iupwinDrawBitmap(hDC, hBitmap, hMask, x, y, width, height, bpp);

    if (hMask)
        DeleteObject(hMask);
}