Click here to Skip to main content
15,888,025 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
SQL
hi
i  have got 150mb image size , when i start my  web application then have to  wait long time.... thats why , i did split into small part
when user drag left hand side two small part join together current display image and left hand side..... similar way right hand side top ...., bottom  like a google map when you drag  image mege it and  cache it help me



<%@ WebHandler Language="C#" Class="ReadImage" %>

using System;
using System.Web;
using System.Data.SqlClient;
using System.IO;
using System.Configuration;
using System.Collections.Generic;
using System.Data;

public class ReadImage : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) 
    {
        Int32 e_id = 1;

        if (context.Request.QueryString["id"] != null)
        {
            e_id = Convert.ToInt32(context.Request.QueryString["id"]);
        }
        else
            throw new ArgumentException("No parameter specified");
        
        context.Response.ContentType = "image/jpeg";
       
        Stream strm = DisplayImage(e_id);
        byte[] buffer = new byte[strm.Length];
        int byteSeq = strm.Read(buffer, 0,(int) strm.Length);

        while (byteSeq > 0)
        {
            context.Response.OutputStream.Write(buffer, 0, byteSeq);
            byteSeq = strm.Read(buffer, 0, (int)strm.Length);
        }
    }
    public Stream DisplayImage(int ID)
    {



        string cs = ConfigurationManager.ConnectionStrings["LocationTrackingConnectionString"].ConnectionString;
        using (SqlConnection connection = new SqlConnection(cs))
        {
            string sql = "SELECT image FROM tblImage WHERE  id  between @ID1 and @ID2 ";
            using (SqlCommand cmd = new SqlCommand(sql, connection))
            {
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Parameters.Add("@ID1",System.Data.SqlDbType.Int).Value=ID;
                cmd.Parameters.Add("@ID2", System.Data.SqlDbType.Int).Value = 20;
                connection.Open();
                SqlDataAdapter adp = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                adp.Fill(ds);
                
                //SqlDataReader theImg = cmd.ExecuteReader();

                object img1 = ds.Tables[0].Rows[0].ItemArray[0];

                object img2 = ds.Tables[0].Rows[1].ItemArray[0];
                                  
                try
                {
                    return new MemoryStream((byte[])img1);
                }
                catch
                {
                    return null;
                }
                finally
                {
                    cmd.Dispose();
                    connection.Close();
                    connection.Dispose();

                }
            }
        }

    }
    public bool IsReusable {
        get {
            return false;
        }
    }

}
Posted
Updated 16-Aug-11 17:44pm
v3
Comments
Sergey Alexandrovich Kryukov 27-Jul-11 14:37pm    
Not a question. What do you want to achieve; what's the problem?
--SA
Christian Graus 16-Aug-11 23:50pm    
What's interesting ?
janwel 17-Aug-11 0:41am    
what kind of picture is that 150mb? Its like your installing a game ^_^

1 solution

There is no reason on earth you need to load a 150 MB image in a web app. Making it in to 50 3 MB images will not speed up the process. Instead, you need make your image smaller. What format is it now ? Convert it to a JPEG or something.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900