Пример #1
0
        public void TestThatFileIsEncodedThenDecodedCorrectly2(NearLosslessPredictorType predictorType)
        {
            var filepathImage = $"{Environment.CurrentDirectory}\\Images\\Peppers256an.bmp";

            TestMethods.CopyFileAndReplaceIfAlreadyExists(filepathImage, filepathSource);

            encoder.Encode(filepathSource, filepathEncodedFile, GetOptions(predictorType));
            decoder.Decode(filepathEncodedFile, filepathDecodedFile);

            Assert.IsTrue(TestMethods.FilesHaveTheSameContent(filepathSource, filepathDecodedFile));
        }
Пример #2
0
 private static NearLosslessOptions GetOptions(NearLosslessPredictorType predictorType)
 {
     return(new NearLosslessOptions
     {
         AcceptedError = 2,
         PredictorType = predictorType,
         SaveMode = NearLosslessErrorMatrixSaveMode.JpegTable,
         PredictionLowerLimit = 0,
         PredictionUpperLimit = 255
     });
 }
        public static INearLosslessPredictor GetPredictor(NearLosslessPredictorType nearLosslessPredictor)
        {
            switch (nearLosslessPredictor)
            {
            case NearLosslessPredictorType.Predictor0:
            {
                return(new NearLosslessPredictor0());
            }

            case NearLosslessPredictorType.Predictor1:
            {
                return(new NearLosslessPredictor1());
            }

            case NearLosslessPredictorType.Predictor2:
            {
                return(new NearLosslessPredictor2());
            }

            case NearLosslessPredictorType.Predictor3:
            {
                return(new NearLosslessPredictor3());
            }

            case NearLosslessPredictorType.Predictor4:
            {
                return(new NearLosslessPredictor4());
            }

            case NearLosslessPredictorType.Predictor5:
            {
                return(new NearLosslessPredictor5());
            }

            case NearLosslessPredictorType.Predictor6:
            {
                return(new NearLosslessPredictor6());
            }

            case NearLosslessPredictorType.Predictor7:
            {
                return(new NearLosslessPredictor7());
            }

            case NearLosslessPredictorType.Predictor8:
            {
                return(new NearLosslessPredictor8());
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(nearLosslessPredictor), nearLosslessPredictor, null);
            }
        }