About Store Forum Documentation Contact
Donations:
158$/mo



Post Reply 
imageDrawPixel - Draw images at pixel coordinates with pixel size
Author Message
Masterxilo Offline
Member

Post: #1
imageDrawPixel - Draw images at pixel coordinates with pixel size
Very short but useful (helped me at least):
Code:
// \param size Use 0 to use the pixel size of the image, ~0 to use the negative pixel size.
    void imageDrawPixel(Image& img, C VecI2& pos = VecI2(0, 0), VecI2 size = VecI2(0, 0))
    {
        if (size.x == 0)  size.x = img.x();
        if (size.y == 0)  size.y = img.y();
        if (size.x == ~0) size.x = -img.x();
        if (size.y == ~0) size.y = -img.y();

        // To screen rect
        Vec2 ssize = D.pixelToScreenSize(size);
        Rect rect = Rect_LU(D.pixelToScreen(pos), ssize.x, ssize.y);
        D.screenAlignToPixel(rect);
        img.draw(rect);
    }

Btw. would you mind adding a "Vec2 lu, Vec2 size" constructor to Rect_LU? Then I wouldn't have to use a temporary.

System: Windows 7 Ultimate 64 bit, Q6600 2.4 GHZ, 4GB RAM, nVidia GeForce 260 GTX 896 MB DDR3

Visit my site: hurricane-eye.webs.com
And read my blog: hurricane-eyeent.blogspot.com
(This post was last modified: 01-07-2011 07:57 PM by Masterxilo.)
01-07-2011 07:36 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply