PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

general Windows API: ImageList_DrawEx

Wondering if anyone else has ever used these API functions. I found some odd behavior, and I'm wondering weither its a bug or intentional.

One of the problems that I can't seem to get around is offset blitting from one of the images. For instance drawing the right edge of an image, without overdraw.

Some info from the docs:
Code:

BOOL ImageList_DrawEx(
HIMAGELIST himl,
int i,
HDC hdcDst,
int x,
int y,
int dx,
int dy,
...


himl - Handle to the image list
i - Index of the image to draw.
hdcDst - Handle to the destination device context.
x - X-coordinate at which to draw within the specified device context.
y - Y-coordinate at which to draw within the specified device context.
dx - Width of the portion of the image to draw relative to the upper-left corner of the image. If dx and dy are zero, the function draws the entire image. The function does not ensure that the parameters are valid.
dy - Height of the portion of the image to draw, relative to the upper-left corner of the image. If dx and dy are zero, the function draws the entire image. The function does not ensure that the parameters are valid.


The parameters in question are dx and dy. In this case 0 is effectively the image width and there is no way for me to offset within the image and draw only the rightmost 10 pixels. So I tried putting a negative number for dx and incrementing the image index by one and it does what I expect. It draws the dx pixels from the right side and clips to that image.

In other words if this is my image list:
I1, I2, I3
and I want to draw the right side of I2, I use "I3" as my index and put a negative dx for the width. It draws the right most dx pixels from I2 and clips to the right edge of I2 (not the image index I asked for in the function call).

The only problem is I have to pad the end with a bogus image or it just fails when I try to index an imaginary "I4", so the i parameter is checked.
I'd treat the "negative dx" as a quirk - it doesn't seem to be documented and so it might be "corrected" at some point.

Can you not just use the <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcesdkr/html/_wcesdk_win32_imagelist_drawindirect.asp">ImageList_DrawIndirect</a> function with an appropriate IMAGELISTDRAWPARAMS structure? (Setting the xBitmap and yBitmap parameters in particular).