Bitmap copyPixelsFromBuffer - 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 copyPixelsFromBuffer method.

This code example shows how to use the following methods:copyPixelsFromBuffer, copyPixelsToBuffer, getConfig, getHeight, getRowBytes
			// android:name="android.permission.WRITE_EXTERNAL_STORAGE" 
			// into AndroidManifest.xml file 
			RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
 
			// get the width and height of the source bitmap. 
			int width = imgIn.getWidth();
			int height = imgIn.getHeight();
			Config type = imgIn.getConfig();
 
			// Copy the byte to the file 
			// Assume source bitmap loaded using options.inPreferredConfig = 
			// Config.ARGB_8888; 
			FileChannel channel = randomAccessFile.getChannel();
			MappedByteBuffer map = channel.map(MapMode.READ_WRITE, 0,
					imgIn.getRowBytes() * height);
			imgIn.copyPixelsToBuffer(map);
			// recycle the source bitmap, this will be no longer used. 
			imgIn.recycle();
			System.gc();// try to force the bytes from the imgIn to be released
 

8
CodeRank
This code example shows how to use the following methods:copyPixelsFromBuffer
    } 
     
    public void copyPixelsFromBuffer() { //�ӻ�������copy�����Լӿ����ش����ٶ�          	 
    	IntBuffer vbb = IntBuffer.wrap(colorArray);    	
        //vbb.put(colorArray); 
        destImage.copyPixelsFromBuffer(vbb);
        vbb.clear();
        //vbb = null; 
    } 
     
    /** 
     * Method to get the RED color for the specified  
     * pixel  
     * @param x 
     * @param y 
     * @return color of R 
     */ 
    public int getRComponent(int x, int y){
         return (getColorArray()[((y*width+x))]& 0x00FF0000) >>> 16;
    } 
7
CodeRank
This code example shows how to use the following methods:copyPixelsFromBuffer
 
    public void DrawByteBuffer() { 
        if(byteBuffer == null)
            return; 
        byteBuffer.rewind();
        bitmap.copyPixelsFromBuffer(byteBuffer);
        DrawBitmap(); 
    } 
 
    public void DrawBitmap() { 
        if(bitmap == null)
            return; 
 
        Canvas canvas = surfaceHolder.lockCanvas();
        if(canvas != null) {
            canvas.drawBitmap(bitmap, srcRect, dstRect, null);
            surfaceHolder.unlockCanvasAndPost(canvas);
        } 
    } 
 
7
CodeRank
This code example shows how to use the following methods:copyPixelsFromBuffer
//        	canvas.drawColor(Color.GREEN); 
        	 
        	nativePixels = ff.getNextDecodedFrame();
        	if(nativePixels != null) {
        		buffer = ByteBuffer.wrap(nativePixels);
            	bitmap.copyPixelsFromBuffer(buffer);
        	} 
        	 
            canvas.drawBitmap(bitmap, 0, 0, p);
        } 
		 
		public void run() {   
            while (!Thread.currentThread().isInterrupted()) {
                try { 
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                } 
                 
                // 使用 postInvalidate 可以直接在线程中更新界面 
7
CodeRank
This code example shows how to use the following methods:copyPixelsFromBuffer, getHeight, getWidth
	boolean fillSmallBitmap(Bitmap bmTest, int position){ // assumes that a 120x120 bitmap is passed
    	/* 
    	 * Sanity check 
    	 */ 
		if(position == -1 || position >= cursor.getCount() || 
				bmTest.getWidth() != 120 || bmTest.getHeight() != 120){
    		return false; 
    	} 
    	 
		/* 
		 * move cursor  
		 */ 
    	cursorSecondary.moveToPosition(position);
    		 
    	/* 
    	 * Get the path to the album art 
    	 */ 
    	albumCoverPath = null;
		artistName = cursorSecondary.getString(
						cursorSecondary.getColumnIndexOrThrow(

5
CodeRank

Related Bitmap copyPixelsFromBuffer Questions & Answers:

copyPixelsFromBuffer Method Overview
Copy the pixels from the buffer, beginning at the current position, overwriting the bitmap's pixels.
See Code Examples for other Android Bitmap Methods: