.net - StrechBlt doesnt work -
protected override void onpaint(painteventargs e) { win32helper.stretchblt(this.handle, 0, 0, 200, 300,bitmap.gethbitmap(), 0, 0, bitmap.width, bitmap.height, win32helper.ternaryrasteroperations.srccopy); this.creategraphics().drawrectangle(new pen(color.black), 0, 0, 100, 100); base.onpaint(e); }
rectangle drawn.. bitmap isnt... have set picturebox1.image=bitmap
, works bitmap isnt empty ... idea doing wrong ? in compact framework.
i'm not sure "this.handle" is, might not handle dc. , suspect leaking resources each creation of pen , graphics object. (the garbage collector release eventually, it's not idea leave these handles lingering around). in case, rather thunking stretchblt, use graphics object image blit.
protected override void onpaint(painteventargs e) { system.drawing.graphics g = e.graphics; // or call creategraphics function pen p = new pen(color.black); g.drawimage(bitmap, 0, 0, 200, 300); g.drawrectangle(p, 0, 0, 100, 100); // cleanup p.dispose(); // g.dispose(); call g.dispose if allocated , didn't come painteventargs parameter base.onpaint(e); }
Comments
Post a Comment