Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IList <IPsdLayer> layers = PsdRenderer.PsdProvider.getVisibleTextLayers("~/1001.psd", Request.QueryString);

            foreach (IPsdLayer l in layers)
            {
                mapdata.Text += "\n<area shape=\"rect\" coords=\"" + l.Rect.X + "," + l.Rect.Y + "," + l.Rect.Right + "," + l.Rect.Bottom + "\" href=\"#\" alt=\"" + l.Name + "\" />";
            }
            yrl y = yrl.Current;

            y.BaseFile = "";
            img.Src   += y.ToString();
        }
        //protected static byte[] GetByteImage(byte[] imageLarge,int width, int height)
        //{
        //    byte[] result = null;
        //    if (imageLarge != null)
        //    {
        //        System.IO.Stream stream = new System.IO.MemoryStream(imageLarge);
        //        result = ResizeFromStream(stream, width,height);
        //    }
        //    return result;
        //}

        //public static byte[] ResizeFromStream(Stream Buffer,int width, int height)
        //{
        //    System.Drawing.Image imgInput = System.Drawing.Image.FromStream(Buffer);
        //    System.Drawing.Imaging.ImageFormat fmtImageFormat = imgInput.RawFormat;
        //    System.Drawing.Bitmap bmpResized = new System.Drawing.Bitmap(imgInput, width, height);
        //    MemoryStream ms = new MemoryStream();
        //    bmpResized.Save(ms, fmtImageFormat);
        //    Byte[] img = ms.ToArray();
        //    imgInput.Dispose();
        //    bmpResized.Dispose();
        //    Buffer.Close();
        //    return img;
        //}
        public void ProceeImage(byte[] buffer, HttpContext context, int width, int height)
        {
            NameValueCollection queryString = new yrl("?maxwidth=" + width.ToString() + "&maxheight=" + height.ToString() + "&format=gif").QueryString;

            context.Response.ContentType = "image/jpeg";
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            ms.Write(buffer, 0, buffer.Length);
            ms.Seek(0, System.IO.SeekOrigin.Begin);
            Bitmap bitmap = new Bitmap(Image.FromStream(ms));

            using (Bitmap img = ImageManager.getBestInstance().BuildImage(bitmap, bitmap.RawFormat, queryString))
            {
                ImageOutputSettings.SaveJpeg(img, 100, context.Response.OutputStream);
            }
        }