c++ - Which Gdiplus::Graphics::DrawImage function should I use? -


i want paste (x,y,w,h) subrectangle src dest, (x,y) source pixel appears (0,0) dest pixel. i'm having difficulty deciding of gazillion overloads this. right code looks this, doesn't work:

auto_ptr<gdiplus::graphics> g(gdiplus::graphics::fromhdc(pdc->getsafehdc())); g->drawimage(png, r.top, r.bottom, r.width(), r.height()); g->flush();  

it doesn't work because (x,y) source pixel appears (x,y) destination pixel, whereas want appear (0,0) destination pixel. source , destination rectangles should have same size different offsets, instead of same offset.

[edit] nevermind, found overloaded function need. turns had add destination (x,y) offset in front, , unitpixel @ end.

auto_ptr<gdiplus::graphics> g(gdiplus::graphics::fromhdc(pdc->getsafehdc())); g->drawimage(png, 0, 0, r.left, r.top, r.width(), r.height(), gdiplus::unitpixel); g->flush(); 

anyone work, work equally well. aliases each other. 1 guess using this one states that:

x [in] real real number specifies x-coordinate of upper-left corner of destination rectangle @ draw image.

y [in] real real number specifies y-coordinate of upper-left corner of destination rectangle @ draw image.

try set x , y values 0 instead, call becomes:

auto_ptr<gdiplus::graphics> g(gdiplus::graphics::fromhdc(pdc->getsafehdc())); g->drawimage(png, 0, 0, r.width(), r.height()); g->flush(); 

other have more specific "doesn't work". incorrectly drawn? not drawn @ all? png correctly loaded? if nothing drawn suggest check return value (which status) drawimage should point in correct direction.


edit

ok, if don't want mapped src(0, 0) dest(0, 0) guess use this one instead. let decide

src[x|y] [in] real real number specifies [x|y]-coordinate of upper-left corner of portion of source image drawn.

hope helps.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -