c# - Select an image from rectangle using writeablebitmap -
i have written application in silverlight, placing rectangle on image , want select part of image covered rectangle , show on image control on click of button.
i not @ handling ratios , image manipulation things, unable right way.
the code same goes below, , appreciate, if suggest me way or solution around this.
public void captureimage(object sender, routedeventargs e) { bitmapimage bitmapimage = new bitmapimage(); //// bitmapimage.createoptions = bitmapcreateoptions.none; bitmapimage = newimage; ////calculate bounding box int originalwidth = bitmapimage.pixelwidth; int originalheight = bitmapimage.pixelheight; int newsmallwidth = (int)squareblue.width; int newsmallheight = (int)squareblue.height; ////generate temporary control render image image temporaryimage = new image { source = bitmapimage, width = newsmallwidth, height = newsmallheight }; ////create writeablebitmap writeablebitmap wb = new writeablebitmap(newsmallwidth, newsmallheight); translatetransform t = new translatetransform(); t.x = -5; t.y = -5; wb.render(temporaryimage, t); wb.invalidate(); myimage.source = wb; } whenever code gets executed, whole image gets snapped, instead of part selected rectangle. anyone, guide me doing wrong here.
i'd recommend use crop method writeablebitmapex library provides.
Comments
Post a Comment