Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to retrieve an Image from database and crop it as per the user needs

i want to crop a photo retrieved from database, i have done the following to retrieve the image from the 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 from 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 that is retrieved is displayed inside the browser.

Now i am stuck at how to crop this image,i want to allow the user to crop the image retrieved from the database and store the cropped image to be passed onto crystal report.

Is this possible? If so than is there any tutorial or help which would guide me to my end requirement.please help me to understand how to proceed with my query

like image 219
Ishan Avatar asked Dec 06 '25 04:12

Ishan


1 Answers

Take a look at GDI+ libraries and also the System.Drawing namespace. You can also use Windows Imaging Components.

Here's a basic walk-through.

like image 90
indra Avatar answered Dec 07 '25 19:12

indra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!