本文整理了Java中android.graphics.Bitmap.getPixels()
方法的一些代码示例,展示了Bitmap.getPixels()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bitmap.getPixels()
方法的具体详情如下:
包路径:android.graphics.Bitmap
类名称:Bitmap
方法名:getPixels
暂无
代码示例来源:origin: CarGuo/GSYVideoPlayer
protected int[] getImageData(Bitmap img) {
int w = img.getWidth();
int h = img.getHeight();
int[] data = new int[w * h];
img.getPixels(data, 0, w, 0, 0, w, h);
return data;
}
代码示例来源:origin: bumptech/glide
int w = image.getWidth();
int h = image.getHeight();
image.getPixels(pixelsInt, 0, w, 0, 0, w, h);
代码示例来源:origin: stackoverflow.com
private Bitmap RGB565toARGB888(Bitmap img) {
int numPixels = img.getWidth()* img.getHeight();
int[] pixels = new int[numPixels];
//Get JPEG pixels. Each int is the color values for one pixel.
img.getPixels(pixels, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight());
//Create a Bitmap of the appropriate format.
Bitmap result = Bitmap.createBitmap(img.getWidth(), img.getHeight(), Bitmap.Config.ARGB_8888);
//Set RGB pixels.
result.setPixels(pixels, 0, result.getWidth(), 0, 0, result.getWidth(), result.getHeight());
return result;
}
代码示例来源:origin: Zomato/AndroidPhotoFilters
public static Bitmap doBrightness(int value, Bitmap inputImage) {
int width = inputImage.getWidth();
int height = inputImage.getHeight();
int[] pixels = new int[width * height];
inputImage.getPixels(pixels, 0, width, 0, 0, width, height);
NativeImageProcessor.doBrightness(pixels, value, width, height);
inputImage.setPixels(pixels, 0, width, 0, 0, width, height);
return inputImage;
}
代码示例来源:origin: Zomato/AndroidPhotoFilters
public static Bitmap doSaturation(Bitmap inputImage, float level) {
int width = inputImage.getWidth();
int height = inputImage.getHeight();
int[] pixels = new int[width * height];
inputImage.getPixels(pixels, 0, width, 0, 0, width, height);
NativeImageProcessor.doSaturation(pixels, level, width, height);
inputImage.setPixels(pixels, 0, width, 0, 0, width, height);
return inputImage;
}
代码示例来源:origin: Zomato/AndroidPhotoFilters
public static Bitmap doContrast(float value, Bitmap inputImage) {
int width = inputImage.getWidth();
int height = inputImage.getHeight();
int[] pixels = new int[width * height];
inputImage.getPixels(pixels, 0, width, 0, 0, width, height);
NativeImageProcessor.doContrast(pixels, value, width, height);
inputImage.setPixels(pixels, 0, width, 0, 0, width, height);
return inputImage;
}
代码示例来源:origin: Zomato/AndroidPhotoFilters
public static Bitmap doColorOverlay(int depth, float red, float green, float blue, Bitmap inputImage) {
int width = inputImage.getWidth();
int height = inputImage.getHeight();
int[] pixels = new int[width * height];
inputImage.getPixels(pixels, 0, width, 0, 0, width, height);
NativeImageProcessor.doColorOverlay(pixels, depth, red, green, blue, width, height);
inputImage.setPixels(pixels, 0, width, 0, 0, width, height);
return inputImage;
}
代码示例来源:origin: chentao0707/SimplifyReader
public static Bitmap doBlurJniArray(Bitmap sentBitmap, int radius, boolean canReuseInBitmap) {
Bitmap bitmap;
if (canReuseInBitmap) {
bitmap = sentBitmap;
} else {
bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
}
if (radius < 1) {
return (null);
}
int w = bitmap.getWidth();
int h = bitmap.getHeight();
int[] pix = new int[w * h];
bitmap.getPixels(pix, 0, w, 0, 0, w, h);
// Jni array calculate
ImageBlur.blurIntArray(pix, w, h, radius);
bitmap.setPixels(pix, 0, w, 0, 0, w, h);
return (bitmap);
}
代码示例来源:origin: yipianfengye/android-zxingLibrary
public BitmapLuminanceSource(Bitmap bitmap) {
super(bitmap.getWidth(), bitmap.getHeight());
// 首先,要取得该图片的像素数组内容
int[] data = new int[bitmap.getWidth() * bitmap.getHeight()];
this.bitmapPixels = new byte[bitmap.getWidth() * bitmap.getHeight()];
bitmap.getPixels(data, 0, getWidth(), 0, 0, getWidth(), getHeight());
// 将int数组转换为byte数组,也就是取像素值中蓝色值部分作为辨析内容
for (int i = 0; i < data.length; i++) {
this.bitmapPixels[i] = (byte) data[i];
}
}
代码示例来源:origin: TheFinestArtist/FinestWebView-Android
public static Bitmap getColoredBitmap(@NonNull Bitmap bitmap, @ColorInt int color) {
int alpha = Color.alpha(color);
int red = Color.red(color);
int green = Color.green(color);
int blue = Color.blue(color);
int[] pixels = new int[bitmap.getWidth() * bitmap.getHeight()];
bitmap.getPixels(pixels, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
for (int i = 0; i < pixels.length; i++) {
int pixel = pixels[i];
int pixelAlpha = Color.alpha(pixel);
if (pixelAlpha != 0) {
pixels[i] = Color.argb((int) (pixelAlpha * alpha / 256f), red, green, blue);
}
}
Bitmap coloredBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
coloredBitmap.setPixels(pixels, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(),
bitmap.getHeight());
return coloredBitmap;
}
代码示例来源:origin: TheFinestArtist/FinestWebView-Android
public static Bitmap getGradientBitmap(int width, int height, @ColorInt int color) {
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
int alpha = Color.alpha(color);
int red = Color.red(color);
int green = Color.green(color);
int blue = Color.blue(color);
int[] pixels = new int[width * height];
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
for (int y = 0; y < height; y++) {
int gradientAlpha = (int) ((float) alpha * (float) (height - y) * (float) (height - y)
/ (float) height
/ (float) height);
for (int x = 0; x < width; x++) {
pixels[x + y * width] = Color.argb(gradientAlpha, red, green, blue);
}
}
bitmap.setPixels(pixels, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
return bitmap;
}
}
代码示例来源:origin: stackoverflow.com
int w = defaultBitmap.getWidth();
int h = defaultBitmap.getHeight();
defaultBitmap.getPixels(pix, 0, w, 0, 0, w, h);
代码示例来源:origin: stackoverflow.com
int width = Math.round(sentBitmap.getWidth() * scale);
int height = Math.round(sentBitmap.getHeight() * scale);
sentBitmap = Bitmap.createScaledBitmap(sentBitmap, width, height, false);
int w = bitmap.getWidth();
int h = bitmap.getHeight();
bitmap.getPixels(pix, 0, w, 0, 0, w, h);
代码示例来源:origin: Zomato/AndroidPhotoFilters
public static Bitmap applyCurves(int[] rgb, int[] red, int[] green, int[] blue, Bitmap inputImage) {
// create output bitmap
Bitmap outputImage = inputImage;
// get image size
int width = inputImage.getWidth();
int height = inputImage.getHeight();
int[] pixels = new int[width * height];
outputImage.getPixels(pixels, 0, width, 0, 0, width, height);
if (rgb != null) {
pixels = NativeImageProcessor.applyRGBCurve(pixels, rgb, width, height);
}
if (!(red == null && green == null && blue == null)) {
pixels = NativeImageProcessor.applyChannelCurves(pixels, red, green, blue, width, height);
}
try {
outputImage.setPixels(pixels, 0, width, 0, 0, width, height);
} catch (IllegalStateException ise) {
}
return outputImage;
}
代码示例来源:origin: ZieIony/Carbon
private static void blurSoftware(Bitmap bitmap, float radius) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int[] pixels = new int[width * height];
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
int[] halfResult = new int[width * height];
int rad = (int) Math.ceil(radius);
代码示例来源:origin: stackoverflow.com
smallBitmap.getWidth(), smallBitmap.getHeight(),
Bitmap.Config.ARGB_8888);
int numPixels = img.getWidth() * img.getHeight();
int[] pixels = new int[numPixels];
img.getPixels(pixels, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight());
代码示例来源:origin: JessYanCoding/MVPArms
int w = bitmap.getWidth();
int h = bitmap.getHeight();
bitmap.getPixels(pix, 0, w, 0, 0, w, h);
代码示例来源:origin: wasabeef/glide-transformations
int w = bitmap.getWidth();
int h = bitmap.getHeight();
bitmap.getPixels(pix, 0, w, 0, 0, w, h);
代码示例来源:origin: qiujuer/Genius-Android
} else if (i == 2) {
int w = overlay.getWidth();
int h = overlay.getHeight();
int[] pix = new int[w * h];
overlay.getPixels(pix, 0, w, 0, 0, w, h);
代码示例来源:origin: chentao0707/SimplifyReader
int w = bitmap.getWidth();
int h = bitmap.getHeight();
bitmap.getPixels(pix, 0, w, 0, 0, w, h);
内容来源于网络,如有侵权,请联系作者删除!