c# - Looking for more efficient software zoom -
i using c#, winforms application aforge library pull video usb camera , manipulate video.
i doing using new frame event handler , posting image picturebox. far, has worked , done want.
however, found out need add software zoom application. solution increase size of overall image , grab section of new, larger image, fit measurements needed. done on every new frame.
int imagetopy; int imagetopx; rectangle rect; bitmap = new bitmap(bitmap, new size(bitmap.width * zoomtrackbar.value, bitmap.height * zoomtrackbar.value)); imagetopy = ((bitmap.height - height) / 2); imagetopx = ((bitmap.width - width) / 2); if (imagetopy != 0 && imagetopx != 0) rect = new rectangle(imagetopx, imagetopy, width, height); else rect = new rectangle(0, 0, width, height); bitmap = (bitmap)bitmap.clone(rect, bitmap.pixelformat)
this need to. however, not @ efficient. when zoome level hits 3, video becomes exceptionally laggy. there latency of 1-2 seconds between video feed , going on. can , little dance, , time sit down in chair, me in video starts doing little dance :-p
any suggestions on better way achieve trying do? maybe more streamlined?
instead of enlarging overall image, cut out section wish zoom in , fill window image. way, having max image size of video window , not enlarging overall image beyond window's constraints.
Comments
Post a Comment