android.widget.ImageView.buildDrawingCache()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(245)

本文整理了Java中android.widget.ImageView.buildDrawingCache()方法的一些代码示例,展示了ImageView.buildDrawingCache()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.buildDrawingCache()方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:buildDrawingCache

ImageView.buildDrawingCache介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

final ImageView im = (ImageView)findViewById(R.id.imageView1) ; 
 im.setBackgroundDrawable(getResources().getDrawable(id1));
 im.setOnClickListener(new OnClickListener() {
  @Override
   public void onClick(View view) {
   Intent intent = new Intent(NAMEOFYOURCURRENTACTIVITY.this, FullScreenImage.class);
   im.buildDrawingCache();
   Bitmap image= im.getDrawingCache();
   Bundle extras = new Bundle();
   extras.putParcelable("imagebitmap", image);
   intent.putExtras(extras);
   startActivity(intent);
               }
             });

代码示例来源:origin: stackoverflow.com

private void drawMatrix(ImageView view){
   float curScale = distCurrent/dist0;
   if (curScale < 0.1){
     curScale = 0.1f;    
   }
   view.buildDrawingCache();
   Bitmap originalBitmap = view.getDrawingCache();
   Bitmap resizedBitmap;    
   int newHeight = (int) (view.getHeight() * curScale);
   int newWidth = (int) (view.getWidth() * curScale);
   resizedBitmap = Bitmap.createScaledBitmap(originalBitmap, newWidth, newHeight, false);
   view.removeallviews();
   view.setImageBitmap(resizedBitmap); 
 }

代码示例来源:origin: stackoverflow.com

public class GetCoordinatesTouchListener implements OnTouchListener {
  public boolean onTouch(View v, MotionEvent event) {
    int eventType = event.getAction() & MotionEvent.ACTION_MASK;
    switch (eventType) {
      case MotionEvent.ACTION_UP:
        ImageView i = (ImageView) v;
        //Save the current bitmap from the imageview
        i.buildDrawingCache();
        Bitmap bm = i.getDrawingCache();
        //Create new overlay bitmap
        Bitmap bmOverlay = Bitmap.createBitmap(i.getWidth(), i.getHeight(), Bitmap.Config.ARGB_8888);
        //Create new drawing canvas and paint
        Canvas c = new Canvas(bmOverlay);
        Paint p = new Paint();
        p.setColor(Color.RED);
        p.setAlpha(50);
        //Draw the saved bitmap onto the canvas
        c.drawBitmap(bm, new Matrix(), null);
        //Draw a circle on the current canvas, centered on event coordinates
        c.drawCircle(event.getX(), event.getY(), 100F, p);
        //Reload the imageview with the new bitmap with FIT_XY scaling
        i.setScaleType(ImageView.ScaleType.FIT_XY);
        i.setImageBitmap(bmOverlay);
      }
    return true;
  }
}

代码示例来源:origin: stackoverflow.com

j = state.getImagePoint().getJ();
ImageView imageView = (ImageView) findViewById(R.id.imageView);
imageView.buildDrawingCache();
Bitmap bitmap = imageView.getDrawingCache();
final ImageView imageFloor = (ImageView) findViewById(R.id.imageView);

代码示例来源:origin: tyhjh/JinyunEffect

@Override
  public void run() {
    //启用DrawingCache并创建位图
    iv_bg.buildDrawingCache();
    while (iv_bg.getDrawingCache() == null) {
      iv_bg.buildDrawingCache();
      SystemClock.sleep(10);
    }
    Bitmap bitmap2 = Bitmap.createBitmap(iv_bg.getDrawingCache());
    bitmap2 = Bitmap.createBitmap(bitmap2, 0, jinyunView.getTop(), jinyunView.getWidth(), jinyunView.getHeight());
    jinyunView.setBitmapBg(bitmap2);
    iv_bg.setDrawingCacheEnabled(false);
  }
}).start();

代码示例来源:origin: Werb/GankWithZhihu

if (granted) { // Always true pre-M
  iv_meizhi_pic.buildDrawingCache();
  Bitmap bitmap = iv_meizhi_pic.getDrawingCache();

代码示例来源:origin: stackoverflow.com

drawIt = false;
imageView.buildDrawingCache();
Bitmap original = imageView.getDrawingCache();

代码示例来源:origin: stackoverflow.com

public boolean onPreDraw() {
  image.getViewTreeObserver().removeOnPreDrawListener(this);
  image.buildDrawingCache();

代码示例来源:origin: bxbxbai/ZhuanLan

@Override
  public boolean onPreDraw() {
    mSplashImage.getViewTreeObserver().removeOnPreDrawListener(this);
    mSplashImage.buildDrawingCache();
    blur(mSplashImage.getDrawingCache(), titleView);
    return true;
  }
});

代码示例来源:origin: wsy858/android-headimage-cliper

/**
 * 获取剪切图
 */
public Bitmap clip() {
  imageView.setDrawingCacheEnabled(true);
  imageView.buildDrawingCache();
  Rect rect = clipView.getClipRect();
  Bitmap cropBitmap = null;
  Bitmap zoomedCropBitmap = null;
  try {
    cropBitmap = Bitmap.createBitmap(imageView.getDrawingCache(), rect.left, rect.top, rect.width(), rect.height());
    zoomedCropBitmap = zoomBitmap(cropBitmap, 200, 200);
  } catch (Exception e) {
    e.printStackTrace();
  }
  if (cropBitmap != null) {
    cropBitmap.recycle();
  }
  // 释放资源
  imageView.destroyDrawingCache();
  return zoomedCropBitmap;
}

代码示例来源:origin: stackoverflow.com

ImageView img= new ImageView();
img=(ImageView) rrr.getChildAt(0);
    img.setRotation(90); 

img.setDrawingCacheEnabled(true);
    img.buildDrawingCache(); 
if(img.isDrawingCacheEnabled()){               
    Bitmap bitmap =img.getDrawingCache(true);             
}img.destroyDrawingCache();
    img.setDrawingCacheEnabled(false);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100,
                bao);

    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Matrix matrix = new Matrix();
    matrix.postRotate(90);
    Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
    BitmapDrawable bmd = new BitmapDrawable(rotatedBitmap); 
    rrr.removeViewAt(0);
    ImageView img_new=new ImageView(ImageSlideShow.this);
    img_new.setImageDrawable(bmd);
    img_new.setScaleType(ScaleType.CENTER);
    rrr.addView(img_new, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

代码示例来源:origin: stackoverflow.com

imageView.buildDrawingCache();
Bitmap bmp = imageView.getDrawingCache();

代码示例来源:origin: stackoverflow.com

public boolean onPreDraw() {
  imViewAndroid.getViewTreeObserver().removeOnPreDrawListener(this);
  imViewAndroid.buildDrawingCache();

代码示例来源:origin: stackoverflow.com

final ImageView tempImageView = new ImageView(getActivity());
final Bitmap tmp = BitmapFactory.decodeFile(LayoutParams.WRAP_CONTENT);
tempImageView.setImageBitmap(tmp);
tempImageView.setDrawingCacheEnabled(true);

// resize and create canvas
tempImageView.measure(MeasureSpec.makeMeasureSpec(256, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(256, MeasureSpec.EXACTLY));
tempImageView.layout(0, 0, tempImageView.getMeasuredWidth(), tempImageView.getMeasuredHeight()); 

tempImageView.buildDrawingCache(true);
final Bitmap resized_bm = Bitmap.createBitmap(tempImageView.getDrawingCache());
tempImageView.setDrawingCacheEnabled(false);

代码示例来源:origin: stackoverflow.com

imageView.buildDrawingCache(true);
File imageFile = new File(Environment.getExternalStorageDirectory(),
    "Pictures/" + UUID.randomUUID().toString() + ".jpg");

代码示例来源:origin: pinguo-zhouwei/EasyBlur

@Override
  public boolean onPreDraw() {
    mImageBg.getViewTreeObserver().removeOnPreDrawListener(this);
    mImageBg.buildDrawingCache();
    Bitmap bmp = mImageBg.getDrawingCache();
    Bitmap overlay = Bitmap.createBitmap((int) (view.getMeasuredWidth()),
        (int) (view.getMeasuredHeight()), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(overlay);
    canvas.translate(-view.getLeft(), -view.getTop());
    canvas.drawBitmap(bmp, 0, 0, null);
    Bitmap finalBitmap = EasyBlur.with(MainActivity.this)
        .bitmap(overlay) //要模糊的图片
        .radius(10)//模糊半径
        .blur();
    view.setBackground(new BitmapDrawable(
        getResources(), finalBitmap));
    return true;
  }
});

代码示例来源:origin: blurpy/kouchat-android

private int getColorFromPreviewImage(final ImageView previewImage) {
  previewImage.buildDrawingCache();
  final Bitmap drawingCache = previewImage.getDrawingCache();
  final int pixelColor = drawingCache.getPixel(10, 10);
  previewImage.destroyDrawingCache();
  return pixelColor;
}

相关文章

ImageView类方法