i use scaled down version of image , drawing on based on mouse events. update result on panel setting .backgroundimage
property. following code.
private void repaint() { bitmap buffer = new bitmap(panel1.width, panel1.height); task.factory.startnew(() => { using (graphics g = graphics.fromimage(buffer)) { // loads large image file bitmap img = new bitmap(images[currentimage]); g.smoothingmode = smoothingmode.antialias; g.clear(systemcolors.control); imgwop = 0.24f * img.width; imghop = 0.24f * img.height; float trans_x = panel1.width / 2 - imgwop / 2; float trans_y = panel1.height / 2 - imghop / 2; // draw scaled version in center of panel g.drawimage(img, trans_x, trans_y, imgwop, imghop); // drawing here g.drawline(...) g.drawellipse(...) } } this.invoke(new action(() => { panel1.backgroundimage = buffer; })); }); }
now, need zoom image includes graphics. need the co-ordinates of graphics draw zoom changes. zoom final bitmap before setting backgroundimage
not scrollbars able see entire image. i've set autoscroll
true.