All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jpedal.parser.image.downsample.DownSampler Maven / Gradle / Ivy

There is a newer version: 7.15.25
Show newest version
/*
 * ===========================================
 * Java Pdf Extraction Decoding Access Library
 * ===========================================
 *
 * Project Info:  http://www.idrsolutions.com
 * Help section for developers at http://www.idrsolutions.com/support/
 *
 * (C) Copyright 1997-2017 IDRsolutions and Contributors.
 *
 * This file is part of JPedal/JPDF2HTML5
 *
 @LICENSE@
 *
 * ---------------
 * DownSampler.java
 * ---------------
 */
package org.jpedal.parser.image.downsample;

import org.jpedal.color.GenericColorSpace;
import org.jpedal.parser.image.data.ImageData;

/**
 * @author markee
 */
public class DownSampler {

    public static GenericColorSpace downSampleImage(GenericColorSpace decodeColorData,
                                                    final ImageData imageData, final byte[] maskCol, final int sampling) {

        if (sampling > 1) { //safety check

            imageData.setIsDownsampled(true);

            switch (imageData.getDepth()) {
                case 1:

                    decodeColorData = OneBitDownSampler.downSample(decodeColorData, maskCol, sampling, imageData);
                    break;

                case 8:
                    decodeColorData = EightBitDownSampler.downSample(imageData, decodeColorData, sampling);
                    break;

            }
        }
        return decodeColorData;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy