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


Java Bitmap.hasAlpha方法代码示例

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


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

示例1: run

import android.graphics.Bitmap; //导入方法依赖的package包/类
public void run() {
    Bitmap bitmap;
    try {
        bitmap = captureView(view);
    }
    catch (Exception e) {
        return;
    }
    if (yflip) {
        Matrix matrix = new Matrix();
        matrix.postScale(1, -1);
        boolean hasAlpha = bitmap.hasAlpha();
        bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
        bitmap.setHasAlpha(hasAlpha);
    }
    int[] textures = new int[1];
    glGenTextures(1, textures, 0);
    glBindTexture(GL_TEXTURE_2D, textures[0]);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    GLUtils.texImage2D(GL_TEXTURE_2D, 0, bitmap, 0);
    this.attachTexture(textures[0]);
}
 
开发者ID:gre,项目名称:react-native-webgl-view-shot,代码行数:24,代码来源:RNWebGLTextureView.java

示例2: getFormat

import android.graphics.Bitmap; //导入方法依赖的package包/类
private Bitmap.CompressFormat getFormat(Bitmap bitmap, Options options) {
  Bitmap.CompressFormat format = options.get(COMPRESSION_FORMAT);
  if (format != null) {
    return format;
  } else if (bitmap.hasAlpha()) {
    return Bitmap.CompressFormat.PNG;
  } else {
    return Bitmap.CompressFormat.JPEG;
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:BitmapEncoder.java

示例3: compress

import android.graphics.Bitmap; //导入方法依赖的package包/类
private static boolean compress(Bitmap bitmap, String outfile, int quality) {
    if (bitmap == null || bitmap.isRecycled())
        return false;

    if (bitmap.hasAlpha()) {
        return CompatCompressor.compress(bitmap, outfile, quality, Bitmap.CompressFormat.PNG);
    } else {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
            return JpegTurboCompressor.compress(bitmap, outfile, quality);
        } else {
            return CompatCompressor.compress(bitmap, outfile, quality, Bitmap.CompressFormat.JPEG);
        }
    }
}
 
开发者ID:tangqipeng,项目名称:tiny,代码行数:15,代码来源:FileCompressor.java

示例4: getOpacity

import android.graphics.Bitmap; //导入方法依赖的package包/类
public int getOpacity() {
    if (this.mGravity != Opcodes.INVOKE_STATIC_RANGE || this.mIsCircular) {
        return -3;
    }
    Bitmap bm = this.mBitmap;
    if (bm == null || bm.hasAlpha() || this.mPaint.getAlpha() < 255 || isGreaterThanZero(this.mCornerRadius)) {
        return -3;
    }
    return -1;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:RoundedBitmapDrawable.java

示例5: compress

import android.graphics.Bitmap; //导入方法依赖的package包/类
protected String compress(Bitmap bitmap, CompressSpec compressSpec) {
    int quality = compressSpec.options.quality;
    String outfile = null;
    float size = compressSpec.options.maxSize;

    if (quality < 0 || quality > 100)
        quality = CompressSpec.DEFAULT_QUALITY;

    if (bitmap.hasAlpha()) {
        outfile = FileUtil.generateCompressOutfileFormatPNG(compressSpec.dir, null).getAbsolutePath();
    } else {
        outfile = FileUtil.generateCompressOutfileFormatJPEG(compressSpec.dir, null).getAbsolutePath();
    }

    boolean isSuccess = compress(bitmap, outfile, quality);

    if (size > 0 && isSuccess) {
        float outfileSize = (float) FileUtil.getSizeInBytes(outfile) / (float) 1024;
        while (outfileSize > size) {
            if (quality <= 25)
                break;
            quality -= 5;
            isSuccess = compress(bitmap, outfile, quality);
            if (!isSuccess)
                break;
            outfileSize = (float) FileUtil.getSizeInBytes(outfile) / (float) 1024;
        }
    }

    Logger.i("final compress quality: " + quality);

    if (bitmap != mT) {
        bitmap.recycle();
        bitmap = null;
        System.gc();
        System.runFinalization();
    }

    return outfile;
}
 
开发者ID:ghnor,项目名称:Flora,代码行数:41,代码来源:CompressCallable.java

示例6: toRoundCornerBitmap

import android.graphics.Bitmap; //导入方法依赖的package包/类
private static Bitmap toRoundCornerBitmap(Canvas canvas, Paint paintClear, Bitmap srcBitmap, float[] roundRadius) {
	if (srcBitmap.isMutable() && srcBitmap.hasAlpha()) {
		return toRoundCornerMutableBitmap(canvas, paintClear, srcBitmap, roundRadius);
	}
	Bitmap output;
	if (false) {
		output = BitmapTools.createBitmapFromRecycledBitmaps(srcBitmap.getWidth(), srcBitmap.getHeight(), XulManager.DEF_PIXEL_FMT);
	} else {
		output = BitmapTools.createBitmap(srcBitmap.getWidth(), srcBitmap.getHeight(), XulManager.DEF_PIXEL_FMT);
	}
	canvas.setBitmap(output);
	Rect rect = new Rect(0, 0, srcBitmap.getWidth(), srcBitmap.getHeight());
	canvas.drawBitmap(srcBitmap, rect, rect, null);
	return toRoundCornerMutableBitmap(canvas, paintClear, output, roundRadius);
}
 
开发者ID:starcor-company,项目名称:starcor.xul,代码行数:16,代码来源:XulWorker.java

示例7: compress

import android.graphics.Bitmap; //导入方法依赖的package包/类
private static boolean compress(Bitmap bitmap, String outfile, int quality) throws FileNotFoundException {
    if (bitmap == null || bitmap.isRecycled())
        return false;

    if (bitmap.hasAlpha()) {
        return CompatCompressor.compress(bitmap, outfile, quality, Bitmap.CompressFormat.PNG);
    } else {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
            return JpegTurboCompressor.compress(bitmap, outfile, quality);
        } else {
            return CompatCompressor.compress(bitmap, outfile, quality, Bitmap.CompressFormat.JPEG);
        }
    }
}
 
开发者ID:Sunzxyong,项目名称:Tiny,代码行数:15,代码来源:FileCompressor.java

示例8: draw

import android.graphics.Bitmap; //导入方法依赖的package包/类
@Override
public void draw(Context context, Canvas canvas) {
    ImageSticker imageSticker = (ImageSticker) sticker;
    if (imageSticker.imageFile == null || imageSticker.imageFile.exists() == false) {
        return;
    }

    BitmapFactory.Options options = new BitmapFactory.Options();

    if (alpha  < 1f) {
        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    }

    Bitmap bitmap = BitmapFactory.decodeFile(imageSticker.imageFile.getAbsolutePath(), options);
    if (alpha < 1f && bitmap.hasAlpha() == false) {
        Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas newCanvas = new Canvas(newBitmap);
        newCanvas.drawBitmap(bitmap, 0, 0, null);

        bitmap.recycle();
        bitmap = newBitmap;
    }

    int canvasWidth = canvas.getWidth();
    int canvasHeight = canvas.getHeight();

    float bitmapWidth = bitmap.getWidth();
    float bitmapHeight = bitmap.getHeight();

    float scale = (canvasWidth * widthRatio) / bitmapWidth ;
    Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, (int) (bitmapWidth * scale), (int) (bitmapHeight * scale), true);
    if (scaledBitmap != bitmap) {
        bitmap.recycle();
    }

    bitmap = scaledBitmap;
    bitmapWidth = bitmap.getWidth();
    bitmapHeight = bitmap.getHeight();

    Matrix matrix = new Matrix();
    matrix.reset();

    matrix.postTranslate((canvasWidth - bitmapWidth) / 2, (canvasHeight - bitmapHeight) / 2);
    matrix.postRotate(angle, canvasWidth / 2, canvasHeight / 2);
    matrix.postTranslate(canvasWidth / 2 * posX, canvasHeight / 2 * posY);

    Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
    paint.setAlpha((int) (alpha * 255));
    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);
    paint.setDither(true);

    canvas.drawBitmap(bitmap, matrix, paint);

    bitmap.recycle();
}
 
开发者ID:monthlypub,项目名称:SmingZZick_App,代码行数:57,代码来源:ImageStickerAttachInfo.java


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