Ejemplo n.º 1
0
        // Token: 0x060000A9 RID: 169 RVA: 0x000097E8 File Offset: 0x000079E8
        public static string GetThumbnail(string imgpath, int maxsize)
        {
            int num = maxsize;

            if (num <= 0)
            {
                num = 600;
            }
            string mapPath = FPUtils.GetMapPath(WebConfig.WebPath);
            string text    = mapPath + imgpath;
            string result;

            if (!File.Exists(text))
            {
                result = "";
            }
            else
            {
                string text2 = Path.GetFileName(imgpath);
                string text3 = Path.GetExtension(imgpath).ToLower();
                if (text3 == ".jpg" || text3 == ".bmp" || text3 == ".png")
                {
                    text2 = Path.GetFileNameWithoutExtension(imgpath);
                    string text4 = string.Format("{0}cache/thumbnail/{1}_{2}{3}", new object[]
                    {
                        WebConfig.WebPath,
                        text2,
                        num,
                        text3
                    });
                    string mapPath2 = FPUtils.GetMapPath(text4);
                    if (!File.Exists(mapPath2))
                    {
                        string mapPath3 = FPUtils.GetMapPath(WebConfig.WebPath + "cache/thumbnail/");
                        if (!Directory.Exists(mapPath3))
                        {
                            try
                            {
                                Directory.CreateDirectory(mapPath3);
                            }
                            catch
                            {
                                throw new Exception("请检查程序目录下cache文件夹的用户权限!");
                            }
                        }
                        FPThumb.CreateThumbnail(mapPath2, text, num);
                    }
                    result = text4;
                }
                else if (text3 == ".gif")
                {
                    result = imgpath;
                }
                else
                {
                    result = "";
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        // Token: 0x060000B8 RID: 184 RVA: 0x0000A0B4 File Offset: 0x000082B4
        public static bool MakeThumbnailImage(string fileName, string newFileName, int maxWidth, int maxHeight, int cropWidth, int cropHeight, int X, int Y)
        {
            byte[] buffer = File.ReadAllBytes(fileName);
            Image  image  = Image.FromStream(new MemoryStream(buffer));
            Bitmap bitmap = new Bitmap(cropWidth, cropHeight);
            bool   result;

            try
            {
                using (Graphics graphics = Graphics.FromImage(bitmap))
                {
                    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    graphics.SmoothingMode     = SmoothingMode.AntiAlias;
                    graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                    graphics.Clear(Color.Transparent);
                    graphics.DrawImage(image, new Rectangle(0, 0, cropWidth, cropHeight), X, Y, cropWidth, cropHeight, GraphicsUnit.Pixel);
                    Image image2 = new Bitmap(bitmap, maxWidth, maxHeight);
                    FPThumb.SaveImage(image2, newFileName, FPThumb.GetCodecInfo("image/" + FPThumb.GetFormat(newFileName).ToString().ToLower()));
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                image.Dispose();
                bitmap.Dispose();
            }
            return(result);
        }
Ejemplo n.º 3
0
        // Token: 0x060000B6 RID: 182 RVA: 0x00009EB8 File Offset: 0x000080B8
        public static void MakeThumbnailImage(string fileName, string newFileName, int maxWidth, int maxHeight)
        {
            byte[] buffer   = File.ReadAllBytes(fileName);
            Image  original = Image.FromStream(new MemoryStream(buffer));

            FPThumb.MakeThumbnailImage(original, newFileName, maxWidth, maxHeight);
        }
Ejemplo n.º 4
0
        // Token: 0x060000B2 RID: 178 RVA: 0x00009CE8 File Offset: 0x00007EE8
        public static void MakeSquareImage(Image image, string newFileName, int newSize)
        {
            int width  = image.Width;
            int height = image.Height;

            if (width > height)
            {
            }
            Bitmap bitmap = new Bitmap(newSize, newSize);

            try
            {
                Graphics graphics = Graphics.FromImage(bitmap);
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                graphics.SmoothingMode     = SmoothingMode.AntiAlias;
                graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                graphics.Clear(Color.Transparent);
                if (width < height)
                {
                    graphics.DrawImage(image, new Rectangle(0, 0, newSize, newSize), new Rectangle(0, (height - width) / 2, width, width), GraphicsUnit.Pixel);
                }
                else
                {
                    graphics.DrawImage(image, new Rectangle(0, 0, newSize, newSize), new Rectangle((width - height) / 2, 0, height, height), GraphicsUnit.Pixel);
                }
                FPThumb.SaveImage(bitmap, newFileName, FPThumb.GetCodecInfo("image/" + FPThumb.GetFormat(newFileName).ToString().ToLower()));
            }
            finally
            {
                image.Dispose();
                bitmap.Dispose();
            }
        }
Ejemplo n.º 5
0
        // Token: 0x060000B9 RID: 185 RVA: 0x0000A1B4 File Offset: 0x000083B4
        public static void MakeRemoteThumbnailImage(string url, string newFileName, int maxWidth, int maxHeight)
        {
            Stream remoteImage = FPThumb.GetRemoteImage(url);

            if (remoteImage != null)
            {
                Image original = Image.FromStream(remoteImage);
                remoteImage.Close();
                FPThumb.MakeThumbnailImage(original, newFileName, maxWidth, maxHeight);
            }
        }
Ejemplo n.º 6
0
        // Token: 0x060000B4 RID: 180 RVA: 0x00009E04 File Offset: 0x00008004
        public static void MakeRemoteSquareImage(string url, string newFileName, int newSize)
        {
            Stream remoteImage = FPThumb.GetRemoteImage(url);

            if (remoteImage != null)
            {
                Image image = Image.FromStream(remoteImage);
                remoteImage.Close();
                FPThumb.MakeSquareImage(image, newFileName, newSize);
            }
        }
Ejemplo n.º 7
0
 // Token: 0x060000AA RID: 170 RVA: 0x0000995C File Offset: 0x00007B5C
 public static void CreateThumbnail(string attPhyCachePath, string attPhyPath, int theMaxsize)
 {
     if (File.Exists(attPhyPath))
     {
         try
         {
             FPThumb.MakeThumbnailImage(attPhyPath, attPhyCachePath, theMaxsize, theMaxsize);
         }
         catch
         {
         }
     }
 }
Ejemplo n.º 8
0
        // Token: 0x060000B5 RID: 181 RVA: 0x00009E40 File Offset: 0x00008040
        public static void MakeThumbnailImage(Image original, string newFileName, int maxWidth, int maxHeight)
        {
            Size newSize = FPThumb.ResizeImage(original.Width, original.Height, maxWidth, maxHeight);

            using (Image image = new Bitmap(original, newSize))
            {
                try
                {
                    image.Save(newFileName, original.RawFormat);
                }
                finally
                {
                    original.Dispose();
                }
            }
        }
Ejemplo n.º 9
0
        // Token: 0x060000B7 RID: 183 RVA: 0x00009EE4 File Offset: 0x000080E4
        public static void MakeThumbnailImage(string fileName, string newFileName, int width, int height, string mode)
        {
            Image image = Image.FromFile(fileName);
            int   num   = width;
            int   num2  = height;
            int   x     = 0;
            int   y     = 0;
            int   num3  = image.Width;
            int   num4  = image.Height;

            if (mode != null)
            {
                if (!(mode == "HW"))
                {
                    if (!(mode == "W"))
                    {
                        if (!(mode == "H"))
                        {
                            if (mode == "Cut")
                            {
                                if ((double)image.Width / (double)image.Height > (double)num / (double)num2)
                                {
                                    num4 = image.Height;
                                    num3 = image.Height * num / num2;
                                    y    = 0;
                                    x    = (image.Width - num3) / 2;
                                }
                                else
                                {
                                    num3 = image.Width;
                                    num4 = image.Width * height / num;
                                    x    = 0;
                                    y    = (image.Height - num4) / 2;
                                }
                            }
                        }
                        else
                        {
                            num = image.Width * height / image.Height;
                        }
                    }
                    else
                    {
                        num2 = image.Height * width / image.Width;
                    }
                }
            }
            Bitmap bitmap = new Bitmap(num, num2);

            try
            {
                Graphics graphics = Graphics.FromImage(bitmap);
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                graphics.SmoothingMode     = SmoothingMode.AntiAlias;
                graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                graphics.Clear(Color.Transparent);
                graphics.DrawImage(image, new Rectangle(0, 0, num, num2), new Rectangle(x, y, num3, num4), GraphicsUnit.Pixel);
                FPThumb.SaveImage(bitmap, newFileName, FPThumb.GetCodecInfo("image/" + FPThumb.GetFormat(newFileName).ToString().ToLower()));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                image.Dispose();
                bitmap.Dispose();
            }
        }
Ejemplo n.º 10
0
 // Token: 0x060000B3 RID: 179 RVA: 0x00009DF0 File Offset: 0x00007FF0
 public static void MakeSquareImage(string fileName, string newFileName, int newSize)
 {
     FPThumb.MakeSquareImage(Image.FromFile(fileName), newFileName, newSize);
 }
Ejemplo n.º 11
0
 // Token: 0x0600006E RID: 110 RVA: 0x000081E8 File Offset: 0x000063E8
 protected string GetThumbnail(string imgpath, int maxsize)
 {
     return(FPThumb.GetThumbnail(imgpath, maxsize));
 }