当前位置: 首页>>代码示例>>Java>>正文


Java Config.ARGB_8888属性代码示例

本文整理汇总了Java中android.graphics.Bitmap.Config.ARGB_8888属性的典型用法代码示例。如果您正苦于以下问题:Java Config.ARGB_8888属性的具体用法?Java Config.ARGB_8888怎么用?Java Config.ARGB_8888使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.graphics.Bitmap.Config的用法示例。


在下文中一共展示了Config.ARGB_8888属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writePixel

/**
 * The reverse function of {@link #readPixel(DataInput)}
 *
 * @param src the bitmap
 * @param dst the sink
 * @throws IOException
 */
public static void writePixel(@Nullable Bitmap src, DataOutput dst) throws IOException {
    if (src != null && src.getConfig() != Config.ARGB_8888) {
        throw new Panic("only bitmaps of the type ARGB_8888 are supported");
    }
    dst.writeBoolean(src != null);
    if (src == null) {
        return;
    }
    dst.writeInt(src.getWidth());
    dst.writeInt(src.getHeight());
    int bytes = src.getWidth() * src.getHeight() * 4;
    dst.writeByte(src.getConfig().ordinal());
    synchronized (BitmapPoolFactory.class) {
        if (sTmp.capacity() < bytes) {
            sTmp = ByteBuffer.allocate(bytes);
        }
        sTmp.clear();
        sTmp.limit(bytes);
        src.copyPixelsToBuffer(sTmp);
        dst.write(sTmp.array(), 0, bytes);
    }
}
 
开发者ID:worldiety,项目名称:homunculus,代码行数:29,代码来源:BitmapPoolFactory.java

示例2: getBitmapFromNative

private static Bitmap getBitmapFromNative(Bitmap bitmap) {
    int width = nativeGetBitmapWidth();
    int height = nativeGetBitmapHeight();

    if (bitmap == null || width != bitmap.getWidth()
            || height != bitmap.getHeight() || !bitmap.isMutable()) { // in
        Config config = Config.ARGB_8888;
        if (bitmap != null) {
            config = bitmap.getConfig();
            bitmap.recycle();
        }
        bitmap = Bitmap.createBitmap(width, height, config);
    }

    int[] pixels = new int[width];
    for (int y = 0; y < height; y++) {
        nativeGetBitmapRow(y, pixels);
        bitmap.setPixels(pixels, 0, width, 0, y, width, 1);
    }

    return bitmap;
}
 
开发者ID:viseator,项目名称:MontageCam,代码行数:22,代码来源:PhotoProcessing.java

示例3: getBytesPerPixel

/**
 * Return the byte usage per pixel of a bitmap based on its configuration.
 * @param config The bitmap configuration.
 * @return The byte usage per pixel.
 */
private static int getBytesPerPixel(Config config) {
    if (config == Config.ARGB_8888) {
        return 4;
    } else if (config == Config.RGB_565) {
        return 2;
    } else if (config == Config.ARGB_4444) {
        return 2;
    } else if (config == Config.ALPHA_8) {
        return 1;
    }
    return 1;
}
 
开发者ID:jjuiddong,项目名称:Android-Practice,代码行数:17,代码来源:ImageCache.java

示例4: compressImageByPixel

/**
 * 按比例缩小图片的像素以达到压缩的目的
 * @author JPH
 * @param imgPath
 * @return 
 * @date 2014-12-5下午11:30:59
 */
private void compressImageByPixel(String imgPath,CompressListener listener) throws FileNotFoundException {
	if(imgPath==null){
		sendMsg(false,imgPath,"要压缩的文件不存在",listener);
		return;
	}
	BitmapFactory.Options newOpts = new BitmapFactory.Options();
	newOpts.inJustDecodeBounds = true;//只读边,不读内容
	BitmapFactory.decodeFile(imgPath, newOpts);
	newOpts.inJustDecodeBounds = false;
	int width = newOpts.outWidth;
	int height = newOpts.outHeight;
	float maxSize =config.getMaxPixel();
	int be = 1;
	if (width >= height && width > maxSize) {//缩放比,用高或者宽其中较大的一个数据进行计算
		be = (int) (newOpts.outWidth / maxSize);
		be++;
	} else if (width < height && height > maxSize) {
		be = (int) (newOpts.outHeight / maxSize);
		be++;
	}
	newOpts.inSampleSize =be;//设置采样率
	newOpts.inPreferredConfig = Config.ARGB_8888;//该模式是默认的,可不设
	newOpts.inPurgeable = true;// 同时设置才会有效
	newOpts.inInputShareable = true;//。当系统内存不够时候图片自动被回收
	Bitmap bitmap = BitmapFactory.decodeFile(imgPath, newOpts);
	if (config.isEnableQualityCompress()){
		compressImageByQuality(bitmap,imgPath,listener);//压缩好比例大小后再进行质量压缩
	}else {
		File thumbnailFile=getThumbnailFile(new File(imgPath));
		bitmap.compress(Bitmap.CompressFormat.JPEG,100,new FileOutputStream(thumbnailFile));

		listener.onCompressSuccess(thumbnailFile.getPath());
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:CompressImageUtil.java

示例5: getBytesPerPixel

/**
 * Return the byte usage per pixel of a bitmap based on its configuration.
 * 
 * @param config
 *            The bitmap configuration.
 * @return The byte usage per pixel.
 */
private static int getBytesPerPixel(Config config) {
	if (config == Config.ARGB_8888) {
		return 4;
	} else if (config == Config.RGB_565) {
		return 2;
	} else if (config == Config.ARGB_4444) {
		return 2;
	} else if (config == Config.ALPHA_8) {
		return 1;
	}
	return 1;
}
 
开发者ID:liuyanggithub,项目名称:SuperSelector,代码行数:19,代码来源:ImageCache.java

示例6: playAnimatedLogo

/**
 * Starts playing the given animated GIF logo.
 */
public void playAnimatedLogo(BaseGifImage gifImage) {
    mLoadingView.hideLoadingUI();
    mAnimatedLogoDrawable = new BaseGifDrawable(gifImage, Config.ARGB_8888);
    mAnimatedLogoMatrix = new Matrix();
    setMatrix(mAnimatedLogoDrawable.getIntrinsicWidth(),
            mAnimatedLogoDrawable.getIntrinsicHeight(), mAnimatedLogoMatrix, false);
    // Set callback here to ensure #invalidateDrawable() is called.
    mAnimatedLogoDrawable.setCallback(this);
    mAnimatedLogoDrawable.start();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:13,代码来源:LogoView.java

示例7: getBitmap

/**
 * Get bitmap from specified image path
 *
 * @param imgPath
 * @return
 */
public static Bitmap getBitmap(String imgPath) {
    // Get bitmap through image path
    BitmapFactory.Options newOpts = new BitmapFactory.Options();
    newOpts.inJustDecodeBounds = false;
    newOpts.inPurgeable = true;
    newOpts.inInputShareable = true;
    // Do not compress
    newOpts.inSampleSize = 1;
    newOpts.inPreferredConfig = Config.ARGB_8888;
    return BitmapFactory.decodeFile(imgPath, newOpts);
}
 
开发者ID:haihaio,项目名称:AmenEye,代码行数:17,代码来源:ImageFactory.java

示例8: loadScaleFile2

public static Bitmap loadScaleFile2(String filename) {

		// return loadFromFile(filename);

		BitmapFactory.Options newOpts = new BitmapFactory.Options();
		// 开始读入图片,此时把options.inJustDecodeBounds 设回true了
		newOpts.inJustDecodeBounds = true;
		Bitmap bitmap = BitmapFactory.decodeFile(filename, newOpts);// 此时返回bm为空

		newOpts.inJustDecodeBounds = false;
		int w = newOpts.outWidth;
		int h = newOpts.outHeight;

		float hh = MainApp.getInstance().getScreenHeight();
		float ww = MainApp.getInstance().getScreenWidth();

		if (w > h) {
			hh = MainApp.getInstance().getScreenWidth();//
			ww = MainApp.getInstance().getScreenHeight();//
		}
		if (w <= ww || h <= hh) {
			return bitmap;
		}
		int be = 1;
		if (w > h && w > ww) {
			be = (int) (newOpts.outWidth / ww);
		} else if (w < h && h > hh) {
			be = (int) (newOpts.outHeight / hh);
		}
		if (be <= 0) {
			be = 1;
		}
		newOpts.inSampleSize = be;// 设置采样率
		newOpts.inPreferredConfig = Config.ARGB_8888;// 该模式是默认的,可不设
		newOpts.inPurgeable = true;// 同时设置才会有效
		newOpts.inInputShareable = true;// 。当系统内存不够时候图片自动被回收

		// newOpts.inSampleSize = calculateInSampleSize(newOpts, 480, 800);

		bitmap = BitmapFactory.decodeFile(filename, newOpts);
		return scaleBitmap(bitmap, ww, hh);
		// */
	}
 
开发者ID:NewCasino,项目名称:browser,代码行数:43,代码来源:BitmapUtil.java


注:本文中的android.graphics.Bitmap.Config.ARGB_8888属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。