// Path: print-api/src/main/java/com/aevi/print/util/Preconditions.java
// public static <T> T checkNotNull(T object, String message) {
//     if (object == null) {
//         throw new IllegalArgumentException(message);
//     }
//     return object;
// }


import com.aevi.util.json.JsonConverter;
import static com.aevi.print.util.Preconditions.checkNotNull;
import android.graphics.Bitmap;
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.aevi.print.model;



/**
 * This class represents an image line in a {@link PrintPayload}.
 */
public class ImageRow implements PrintRow {

    private static final int DEFAULT_CONTRAST_LEVEL = 50;

    private final Bitmap image;
    private final boolean scaleToFit;
    private Alignment alignment = Alignment.LEFT;
    private int contrastLevel = DEFAULT_CONTRAST_LEVEL;

    /**
     * Creates a left aligned image row at normal contrast (50) with the given
     * bitmap.
     *
     * NOTE: If the (unscaled) image is too large to print onto the page it <strong>will</strong> be scaled by the printer driver to fit the width.
     *
     * @param image the image to print. This parameter must not be null.
     */
    public ImageRow(Bitmap image) {
        this(image, true);
    }

    /**
     * Creates a left aligned image row at normal contrast (50) with the given
     * bitmap.
     *
     * @param image      the image to print. This parameter must not be null.
     * @param scaleToFit If true the image will be scaled down to fit the page if it is too large. If false the image will be cropped.
     */
    public ImageRow(Bitmap image, boolean scaleToFit) {
// Path: print-api/src/main/java/com/aevi/print/util/Preconditions.java
// public static <T> T checkNotNull(T object, String message) {
//     if (object == null) {
//         throw new IllegalArgumentException(message);
//     }
//     return object;
// }


// Path: print-api/src/main/java/com/aevi/print/model/ImageRow.java
import com.aevi.util.json.JsonConverter;
import static com.aevi.print.util.Preconditions.checkNotNull;
import android.graphics.Bitmap;

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.aevi.print.model;



/**
 * This class represents an image line in a {@link PrintPayload}.
 */
public class ImageRow implements PrintRow {

    private static final int DEFAULT_CONTRAST_LEVEL = 50;

    private final Bitmap image;
    private final boolean scaleToFit;
    private Alignment alignment = Alignment.LEFT;
    private int contrastLevel = DEFAULT_CONTRAST_LEVEL;

    /**
     * Creates a left aligned image row at normal contrast (50) with the given
     * bitmap.
     *
     * NOTE: If the (unscaled) image is too large to print onto the page it <strong>will</strong> be scaled by the printer driver to fit the width.
     *
     * @param image the image to print. This parameter must not be null.
     */
    public ImageRow(Bitmap image) {
        this(image, true);
    }

    /**
     * Creates a left aligned image row at normal contrast (50) with the given
     * bitmap.
     *
     * @param image      the image to print. This parameter must not be null.
     * @param scaleToFit If true the image will be scaled down to fit the page if it is too large. If false the image will be cropped.
     */
    public ImageRow(Bitmap image, boolean scaleToFit) {
        this.image = checkNotNull(image, "image must not be null");