Exemplo n.º 1
0
        public static bool ChangeImageNotChange(string sourceFileFullName, long maxLength, string targetFileFullName)
        {
            Stream stream = null;
            bool   result = true;

            try
            {
                bool   flag  = false;
                byte[] array = ImageCompress.CompressImageNotChange(sourceFileFullName, maxLength, out flag);
                if (flag || !(sourceFileFullName == targetFileFullName))
                {
                    stream = File.Create(targetFileFullName);
                    stream.Write(array, 0, array.Length);
                }
            }
            catch (Exception ex)
            {
                Log.WriteLog(ex);
                result = false;
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                    stream.Dispose();
                }
            }
            return(result);
        }
Exemplo n.º 2
0
 public static byte[] CompressImageNotChange(string sourceFileFullName, long maxLength, out bool hasCompress)
 {
     hasCompress = false;
     byte[] imageToByteArrayByFile = ImageCompress.GetImageToByteArrayByFile(sourceFileFullName);
     if (imageToByteArrayByFile == null || (long)imageToByteArrayByFile.Length <= maxLength)
     {
         return(imageToByteArrayByFile);
     }
     hasCompress = true;
     return(ImageCompress.CompressImageNotChange(imageToByteArrayByFile, maxLength, ref sourceFileFullName));
 }