Exemplo n.º 1
0
        public static void SaveTiff(string path, Bitmap image, SaveFormatEnum saveFormat = SaveFormatEnum.TIFF)
        {
            long compression;

            switch (saveFormat)
            {
            case SaveFormatEnum.TIFF:
                compression = (long)EncoderValue.CompressionNone;
                break;

            case SaveFormatEnum.TIFFLZW:
                compression = (long)EncoderValue.CompressionLZW;
                break;

            default:
                compression = (long)EncoderValue.CompressionNone;
                break;
            }

            using (EncoderParameters encoderParameters = new EncoderParameters(1))
                using (EncoderParameter encoderParameter = new EncoderParameter(Encoder.Compression, compression))
                {
                    ImageCodecInfo codecInfo = ImageCodecInfo.GetImageDecoders().First(codec => codec.FormatID == ImageFormat.Tiff.Guid);
                    encoderParameters.Param[0] = encoderParameter;
                    image.Save(path, codecInfo, encoderParameters);
                }
        }
Exemplo n.º 2
0
        private static void saveImage(string outputFilePath, Bitmap image, SaveFormatEnum saveFormat)
        {
            switch (saveFormat)
            {
            case SaveFormatEnum.TIFF:
                outputFilePath = Path.ChangeExtension(outputFilePath, "tif");
                SaveHelper.SaveTiff(outputFilePath, image, saveFormat);
                break;

            case SaveFormatEnum.TIFFLZW:
                outputFilePath = Path.ChangeExtension(outputFilePath, "tif");
                SaveHelper.SaveTiff(outputFilePath, image, saveFormat);
                break;

            case SaveFormatEnum.JPG90:
                outputFilePath = Path.ChangeExtension(outputFilePath, "jpg");
                SaveHelper.SaveJpeg(outputFilePath, image, 90L);
                break;

            case SaveFormatEnum.JPG100:
                outputFilePath = Path.ChangeExtension(outputFilePath, "jpg");
                SaveHelper.SaveJpeg(outputFilePath, image, 100L);
                break;

            default:
                break;
            }
        }
Exemplo n.º 3
0
 public ProcessingConfiguration(SaveFormatEnum saveFormat, RotateFinalImageEnum rotateFinalImage, bool shouldCropImage, int maxHeight, int maxWidth)
 {
     SaveFormat       = saveFormat;
     RotateFinalImage = rotateFinalImage;
     ShouldCropImage  = shouldCropImage;
     MaxCroppedHeight = maxHeight;
     MaxCroppedWidth  = maxWidth;
 }
Exemplo n.º 4
0
 public ProcessingConfiguration(SaveFormatEnum saveFormat, bool shouldGenerateMinis, int minisFactor, bool shouldDrawBorder, int borderThickness,
                                RotateFinalImageEnum rotateFinalImage, bool shouldCropImage, int maxHeight, int maxWidth)
 {
     SaveFormat          = saveFormat;
     ShouldGenerateMinis = shouldGenerateMinis;
     MinisFactor         = minisFactor;
     ShouldDrawBorder    = shouldDrawBorder;
     BorderThickness     = borderThickness;
     RotateFinalImage    = rotateFinalImage;
     ShouldCropImage     = shouldCropImage;
     MaxCroppedHeight    = maxHeight;
     MaxCroppedWidth     = maxWidth;
 }