<commit_before>package com.cv4j.core.datamodel;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;

import com.cv4j.exception.CV4JException;
import com.cv4j.image.util.IOUtils;

import java.io.InputStream;
import java.io.Serializable;

public class ColorImage implements ImageData,Serializable {

	private static final long serialVersionUID = -6258992466268616924L;

	private int[] pdata;
	private int width;
	private int height;
	private int type;

	public ColorImage(Bitmap bitmap) {
		if (bitmap == null) {
			throw new CV4JException("bitmap is null");
		}

		width = bitmap.getWidth();
		height = bitmap.getHeight();
		pdata = new int[width*height];
		bitmap.getPixels(pdata, 0, width, 0, 0, width, height);
	}

	public ColorImage(InputStream inputStream) {
		if (inputStream == null) {
			throw new CV4JException("inputStream is null");
		}

		Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
		width = bitmap.getWidth();
		height = bitmap.getHeight();
		pdata = new int[width*height];
		bitmap.getPixels(pdata, 0, width, 0, 0, width, height);

		IOUtils.closeQuietly(inputStream);
	}

	@Override
	public int[] getPixels() {
		return pdata;
	}

	@Override
	public int getWidth() {
		return width;
	}

	@Override
	public int getHeight() {
		return height;
	}

	@Override
	public int getType() {
		return this.type;
	}

	@Override
	public byte[] getChannel(int index) {<commit_msg>增加ColorImage构造函数<commit_after>package com.cv4j.core.datamodel;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;

import com.cv4j.exception.CV4JException;
import com.cv4j.image.util.IOUtils;

import java.io.InputStream;
import java.io.Serializable;

public class ColorImage implements ImageData,Serializable {

	private static final long serialVersionUID = -6258992466268616924L;

	private int[] pdata;
	private int width;
	private int height;
	private int type;

	public ColorImage(Bitmap bitmap) {
		if (bitmap == null) {
			throw new CV4JException("bitmap is null");
		}

		width = bitmap.getWidth();
		height = bitmap.getHeight();
		pdata = new int[width*height];
		bitmap.getPixels(pdata, 0, width, 0, 0, width, height);
	}

	public ColorImage(InputStream inputStream) {
		if (inputStream == null) {
			throw new CV4JException("inputStream is null");
		}

		Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
		width = bitmap.getWidth();
		height = bitmap.getHeight();
		pdata = new int[width*height];
		bitmap.getPixels(pdata, 0, width, 0, 0, width, height);

		IOUtils.closeQuietly(inputStream);
	}

	public ColorImage(byte[] bytes) {
		if (bytes == null) {
			throw new CV4JException("byte is null");
		}

		Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
		width = bitmap.getWidth();
		height = bitmap.getHeight();
		pdata = new int[width*height];
		bitmap.getPixels(pdata, 0, width, 0, 0, width, height);
	}

	@Override
	public int[] getPixels() {
		return pdata;
	}

	@Override
	public int getWidth() {
		return width;
	}

	@Override
	public int getHeight() {
		return height;
	}

	@Override
	public int getType() {
		return this.type;
	}

	@Override
	public byte[] getChannel(int index) {
{'fraction_non_alphanumeric': 0.11761045426260112, 'fraction_numerical': 0.020846297448662104, 'mean_word_length': 4.486348122866894, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '254207', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1080, 'n_words': 274}