Bitmap getPixels - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Bitmap getPixels method.

This code example shows how to use the following methods:getHeight, getPixels, getWidth
		System.loadLibrary("AndroidImageFilter");
	} 
	 
 
	public static Bitmap changeToNeon(Bitmap bitmap) {
		int width = bitmap.getWidth();
		int height = bitmap.getHeight();
		 
		Bitmap returnBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
		int[] pixels = new int[width * height];
		bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
		 
		int[] returnPixels = NativeFilterFunc.neonFilter(pixels, width, height);
		Log.d("AndroidImageFilter", "returnPixles[1] = " + returnPixels[1]);
		returnBitmap.setPixels(returnPixels, 0, width, 0, 0, width, height);
		 
		return returnBitmap;
	} 
} 
7
CodeRank
This code example shows how to use the following methods:copy, getHeight, getPixels, getWidth, recycle
    public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
        // TODO: implement bilinear or bicubic here... for now, just use 
        // canvas to do a simple implementation... 
        // TODO: and be more memory efficient! (do it in native?) 
 
        Bitmap temp = bitmap.copy(mConfig, true);
        Canvas canvas = new Canvas(temp);
        canvas.save();
        Rect bounds = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
        float w = temp.getWidth();
        float h = temp.getHeight();
        float mw = temp.getWidth() / 2.0f;
        float mh = temp.getHeight() / 2.0f;
 
        canvas.scale(mZoomFactor, mZoomFactor, mw, mh);
        canvas.rotate(mRotation, mw, mh);
        canvas.drawBitmap(bitmap, bounds, bounds, new Paint());
        canvas.restore();
 
        int[] pixels = new int[(int) (w * h)];

7
CodeRank
This code example shows how to use the following methods:getConfig, getHeight, getPixels, getWidth
package cc.omora.android.brokencamera.breakers; 
import cc.omora.android.brokencamera.Breaker; 
import android.graphics.Bitmap; 
import java.util.Arrays; 
 
public class SortPixels extends Breaker { 
    public Bitmap breakData(Bitmap source, int level) {
        final int width = source.getWidth();
        final int height = source.getHeight();
        int pixels[] = new int[width * height];
        Bitmap bitmap = Bitmap.createBitmap(width, height, source.getConfig());
 
        source.getPixels(pixels, 0, width, 0, 0, width, height);
        Arrays.sort(pixels);
        bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
 
        return bitmap;
    } 
} 

7
CodeRank
This code example shows how to use the following methods:getHeight, getPixels, getWidth
		float actionbarHeight = ACTION_BAR_HEIGHT * activity.getResources().getDisplayMetrics().density;
		return actionbarHeight;
	} 
 
	public static int[] bitmapToPixelArray(Bitmap bitmap) {
		int bitmapWidth = bitmap.getWidth();
		int bitmapHeight = bitmap.getHeight();
		int pixelArray[] = new int[bitmapWidth * bitmapHeight];
		bitmap.getPixels(pixelArray, 0, bitmapWidth, 0, 0, bitmapWidth, bitmapHeight);
		return pixelArray;
	} 
 
	public static synchronized Point convertFromCanvasToScreen(Point canvasPoint, Perspective currentPerspective)
			throws SecurityException, IllegalArgumentException, NoSuchFieldException, IllegalAccessException { 
		Float surfaceCenterX = (Float) PrivateAccess.getMemberValue(Perspective.class, currentPerspective,
				"mSurfaceCenterX"); 
		Float surfaceScale = (Float) PrivateAccess.getMemberValue(Perspective.class, currentPerspective,
				"mSurfaceScale"); 
		Float surfaceTranslationX = (Float) PrivateAccess.getMemberValue(Perspective.class, currentPerspective,
				"mSurfaceTranslationX"); 
6
CodeRank
This code example shows how to use the following methods:getHeight, getPixels, getWidth
		} 
		return ret;
	} 
 
	public static Bitmap ResizeCutToSquare(Bitmap bmp) {
		int width = bmp.getWidth();
		int height = bmp.getHeight();
		int size = Math.min(width, height);
		// Matrix matrix = new Matrix(); 
		int pixels[] = new int[size * size];
		int stride = Math.max(width, height);
		bmp.getPixels(pixels, 0, size, Math.max(0, (width - height) / 2),
				Math.max(0, (height - width) / 2), size, size);
 
		Bitmap ret = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
		ret.setPixels(pixels, 0, size, 0, 0, size, size);
		/* 
		 * if (width > height) { ret.setPixels(pixels, 0, width, 0, (width - 
		 * height) / 2, width, height); } else { ret.setPixels(pixels, 0, width, 
		 * (height - width) / 2, 0, width, height); } 
6
CodeRank
This code example shows how to use the following methods:getHeight, getPixels, getWidth
		} 
		return IntBuffer.wrap(pPixels);
	} 
 
	public static int[] getPixels(final Bitmap pBitmap) {
		final int w = pBitmap.getWidth();
		final int h = pBitmap.getHeight();
 
		final int[] pixels = new int[w * h];
		pBitmap.getPixels(pixels, 0, w, 0, 0, w, h);
 
		return pixels;
	} 
 
	// =========================================================== 
	// Inner and Anonymous Classes 
	// =========================================================== 
} 
6
CodeRank
This code example shows how to use the following methods:getPixels, isRecycled
		return Color.TRANSPARENT;
	} 
 
	public void getPixels(int[] pixels, int offset, int stride, int x, int y,
			int width, int height) {
		if (mWorkingBitmap != null && mWorkingBitmap.isRecycled() == false) {
			mWorkingBitmap.getPixels(pixels, offset, stride, x, y, width,
					height);
		} 
	} 
 
	public int getBitmapWidth() { 
		if (mWorkingBitmap == null) {
			return -1; 
		} 
		return mWorkingBitmap.getWidth();
	} 
 
	public int getBitmapHeight() { 
		if (mWorkingBitmap == null) {
5
CodeRank
This code example shows how to use the following methods:getPixels
 
    @Override 
    protected void getNativeARGBData(int[] aRgbData, int aOffset,
            int aScanlength, int aX, int aY, int aWidth, int aHeight) {
         
        iBitmap.getPixels(aRgbData, aOffset, aScanlength, aX, aY, aWidth, aHeight);
    } 
 
    @Override 
    public Object getNativeImage() {
        return iBitmap;
    } 
 
    @Override 
    public WFGraphics getWFGraphics() { 
        return new AndroidGraphics(iBitmap);
    } 
 
    @Override 
    public boolean hasNativeImage() { 
5
CodeRank
This code example shows how to use the following methods:getPixels
      ripple = new int[width*height];
      texture = new int[width*height];
      oldind = width;
      newind = width * (height+3);
      System.out.println("getpixels");
 image.getPixels(texture, 0, width, 0,0,width,height);
     // PixelGrabber pg = new PixelGrabber(im,0,0,width,height,texture,0,width); 
      //try { 
      //  pg.grabPixels(); 
       // } catch (InterruptedException e) {} 
 
 
      //source = new MemoryImageSource(width, height, ripple, 0, width); 
      //source.setAnimated(true); 
     // source.setFullBufferUpdates(true); 
      //  source=Bitmap.createBitmap(ripple,width,height,Bitmap.Config.ARGB_4444); 
         
     // image = Bitmap.createBitmap(source); 
     // offImage = Bitmap.createBitmap(width, height,Bitmap.Config.ARGB_4444); 
      //offGraphics = offImage.getGraphics(); 
4
CodeRank
This code example shows how to use the following methods:getPixels
	 * @throws NullPointerException - if rgbData is null 
	 * @since  MIDP 2.0 
	 */ 
	public void getRGB(int[] rgbData, int offset, int scanlength, int x, int y, int width, int height)
	{ 
		this.bitmap.getPixels(rgbData, offset, scanlength, x, y, width, height);
	} 
	 
	/** 
	 * Retrives the native BlackBerry bitmap that is wrapped by this image. 
	 *  
	 * @return the native BlackBerry bitmap that is wrapped by this image. 
	 */ 
	public Bitmap getBitmap() {
		return this.bitmap;
	} 
 
} 
4
CodeRank

Related Bitmap getPixels Questions & Answers:

getPixels Method Overview
Returns in pixels[] a copy of the data in the bitmap.
See Code Examples for other Android Bitmap Methods: