Esempio n. 1
0
        public static new MemoryStreamImageProxy FromImage(System.Drawing.Image image, string name)
        {
            var          img = new MemoryStreamImageProxy();
            MemoryStream str1, str2;
            string       fmt1, fmt2;

            if (image is Metafile)
            {
                var mf = (Metafile)image;

                fmt1 = ".emf";
                str1 = ImageToStream(image, ImageFormat.Emf);
                fmt2 = ".png";
                str2 = ImageToStream(image, ImageFormat.Png);
            }
            else
            {
                fmt1 = ".jpg";
                str1 = ImageToStream(image, ImageFormat.Jpeg);
                fmt2 = ".png";
                str2 = ImageToStream(image, ImageFormat.Png);
            }

            if (str2.Length < str1.Length)
            {
                img._stream    = str2;
                img._extension = fmt2;
                str1.Dispose();
            }
            else
            {
                img._stream    = str1;
                img._extension = fmt1;
                str2.Dispose();
            }

            img.ComputeStreamHash();

            if (string.IsNullOrEmpty(name))
            {
                img._name = img._hash + img._extension;
                img._url  = "image://" + img._name;
            }
            else
            {
                img._name = name;
                img._url  = "image://" + name;
            }

            return(img);
        }
Esempio n. 2
0
        public static MemoryStreamImageProxy FromImage(System.Drawing.Image image, string name)
        {
            MemoryStreamImageProxy img = new MemoryStreamImageProxy();

            img._url   = "image://" + name;
            img._name  = name;
            img._image = image;
            MemoryStream str1;
            MemoryStream str2;

            if (image is Metafile)
            {
                Metafile mf = (Metafile)image;

                str1 = ImageToStream(image, ImageFormat.Emf);
                str2 = ImageToStream(image, ImageFormat.Png);
            }
            else
            {
                str1 = ImageToStream(image, ImageFormat.Jpeg);
                str2 = ImageToStream(image, ImageFormat.Png);
            }

            if (str2.Length < str1.Length)
            {
                img._stream = str2;
                str1.Dispose();
            }
            else
            {
                img._stream = str1;
                str2.Dispose();
            }

            img.ComputeStreamHash();
            return(img);
        }
Esempio n. 3
0
    public static MemoryStreamImageProxy FromImage(System.Drawing.Image image, string name)
    {
      MemoryStreamImageProxy img = new MemoryStreamImageProxy();
      img._url = "image://" + name;
      img._name = name;
      img._image = image;
      MemoryStream str1;
      MemoryStream str2;
      if (image is Metafile)
      {
        Metafile mf = (Metafile)image;

        str1 = ImageToStream(image, ImageFormat.Emf);
        str2 = ImageToStream(image, ImageFormat.Png);
      }
      else
      {
        str1 = ImageToStream(image, ImageFormat.Jpeg);
        str2 = ImageToStream(image, ImageFormat.Png);
      }

      if (str2.Length < str1.Length)
      {
        img._stream = str2;
        str1.Dispose();
      }
      else
      {
        img._stream = str1;
        str2.Dispose();
      }

      img.ComputeStreamHash();
      return img;
    }