c# - I want to retrieve an Image from database and crop it as per the user needs -
i want crop photo retrieved database, have done following retrieve image database
protected void page_load(object sender, eventargs e) { memorystream stream = new memorystream(); sqlconnection connection = new sqlconnection(@"data source=localhost;initial catalog=card;user id=sa;password=db2admin;"); try { connection.open(); sqlcommand command = new sqlcommand("select photo iffcar", connection); byte[] image = (byte[])command.executescalar(); stream.write(image, 0, image.length); bitmap bitmap = new bitmap(stream); response.contenttype = "image/gif"; bitmap.save(response.outputstream, imageformat.jpeg); } catch (exception ee) { connection.close(); stream.close(); httpcontext.current.response.write(ee.message); } }
the image retrieved displayed inside browser.
now stuck @ how crop image,i want allow user crop image retrieved database , store cropped image passed onto crystal report.
is possible? if there tutorial or guide me end requirement.please me understand how proceed query
fill in ??s , try this:
connection.open(); sqlcommand command = new sqlcommand("select photo iffcar", connection); byte[] image = (byte[])command.executescalar(); stream.write(image, 0, image.length); bitmap bitmap = new bitmap(stream); int croppedwidth = ??, croppedheight = ??, cropoffsetx = ??, cropoffsety = ??; var croppedbitmap = new bitmap(croppedwidth, croppedheight); var graphics = graphics.fromimage(croppedbitmap); graphics.drawimage(bitmap, -cropoffsetx, -cropoffsety, bitmap.width, bitmap .height); response.contenttype = "image/gif"; croppedbitmap.save(response.outputstream, imageformat.jpeg);
Comments
Post a Comment