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

This code example shows how to use the following methods:copyPixelsToBuffer, getHeight, getRowBytes, getWidth
        } 
        return bmp;
    } 
     
    private static void compareImages(Bitmap bmp1, Bitmap bmp2) {
        assertTrue(bmp1.getHeight() == bmp2.getHeight());
        assertTrue(bmp1.getWidth() == bmp1.getWidth());
        ByteBuffer buffer1 = ByteBuffer.allocate(bmp1.getHeight() * bmp1.getRowBytes());
        bmp1.copyPixelsToBuffer(buffer1);
 
        ByteBuffer buffer2 = ByteBuffer.allocate(bmp2.getHeight() * bmp2.getRowBytes());
        bmp2.copyPixelsToBuffer(buffer2);
 
        assertTrue(Arrays.equals(buffer1.array(), buffer2.array()));
    } 
 
    private Context safeGetContext() {
        for (;;) { 
            if ((getContext() != null) && (getContext().getApplicationContext() != null)) {
                return getContext();
9
CodeRank
This code example shows how to use the following methods:getHeight, getRowBytes
		super(sizeLimit);
	} 
 
	@Override 
	public boolean put(String key, Bitmap value) {
		if (super.put(key, value)) {
			valueSizes.put(value, getSize(value));
			return true; 
		} else { 
			return false; 
		} 
	} 
 
	@Override 
	public void remove(String key) {
		Bitmap value = super.get(key);
		if (value != null) {
			valueSizes.remove(value);
		} 
		super.remove(key);

9
CodeRank
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:getHeight, getRowBytes
		super.clear(); 
	} 
 
	@Override 
	protected int getSize(Bitmap value) {
		return value.getRowBytes() * value.getHeight();
	} 
 
	@Override 
	protected Bitmap removeNext() {
		return queue.remove(0);
	} 
 
	@Override 
	protected Reference<Bitmap> createReference(Bitmap value) {
		return new WeakReference<Bitmap>(value);
	} 
} 
8
CodeRank
This code example shows how to use the following methods:getHeight, getRowBytes
		super.clear(); 
	} 
 
	@Override 
	protected int getSize(Bitmap value) {
		return value.getRowBytes() * value.getHeight();
	} 
 
	@Override 
	protected Bitmap removeNext() {
		Bitmap mostLongUsedValue = null;
		synchronized (lruCache) {
			Iterator<Entry<String, Bitmap>> it = lruCache.entrySet().iterator();
			if (it.hasNext()) {
				Entry<String, Bitmap> entry = it.next();
				mostLongUsedValue = entry.getValue();
				it.remove();
			} 
		} 
		return mostLongUsedValue;
8
CodeRank
This code example shows how to use the following methods:getHeight, getRowBytes
		super.clear(); 
	} 
 
	@Override 
	protected int getSize(Bitmap value) {
		return value.getRowBytes() * value.getHeight();
	} 
 
	@Override 
	protected Bitmap removeNext() {
		Integer minUsageCount = null;
		Bitmap leastUsedValue = null;
		Set<Entry<Bitmap, Integer>> entries = usingCounts.entrySet();
		synchronized (usingCounts) {
			for (Entry<Bitmap, Integer> entry : entries) {
				if (leastUsedValue == null) {
					leastUsedValue = entry.getKey();
					minUsageCount = entry.getValue();
				} else { 
					Integer lastValueUsage = entry.getValue();
8
CodeRank
This code example shows how to use the following methods:getHeight, getRowBytes
	 * Returns the size {@code Bitmap} in bytes. 
	 * <p/> 
	 * An entry's size must not change while it is in the cache. 
	 */ 
	private int sizeOf(String key, Bitmap value) {
		return value.getRowBytes() * value.getHeight();
	} 
 
	@Override 
	public synchronized final String toString() {
		return String.format("LruCache[maxSize=%d]", maxSize);
	} 
} 
8
CodeRank
This code example shows how to use the following methods:copyPixelsToBuffer, getHeight, getRowBytes
This code example shows how to use the following methods:getHeight, getRowBytes
    @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
    @Override 
    protected int sizeOf(Object key, CacheItem<Bitmap> value) {
        Bitmap data = value.getData();
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) {
            return data.getRowBytes() * data.getHeight();
        } else { 
            return data.getByteCount();
        } 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getHeight, getRowBytes
        super(maxSize);
    } 
 
    @Override 
    protected int sizeOf(String key, Bitmap value) {
        return value.getRowBytes() * value.getHeight();
    } 
} 
7
CodeRank

Related Bitmap getRowBytes Questions & Answers:

Other Bitmap getRowBytes Examples

24:		@Override
25:		protected int sizeOf(String key, Bitmap value) {
26:			return value.getRowBytes() * value.getHeight() / 1024;
27:		}
28:

Read More

getRowBytes Method Overview
Return the number of bytes between rows in the bitmap's pixels.
See Code Examples for other Android Bitmap Methods: