Java Code Examples for android.graphics.Matrix

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Alerte-voirie-android, under directory /src/com/c4mprod/utils/.

Source file: Flip3dAnimation.java

  34 
vote

@Override protected void applyTransformation(float interpolatedTime,Transformation t){
  final float fromDegrees=mFromDegrees;
  float degrees=fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
  final float centerX=mCenterX;
  final float centerY=mCenterY;
  final Camera camera=mCamera;
  final Matrix matrix=t.getMatrix();
  camera.save();
  camera.rotateY(degrees);
  camera.getMatrix(matrix);
  camera.restore();
  matrix.preTranslate(-centerX,-centerY);
  matrix.postTranslate(centerX,centerY);
}
 

Example 2

From project Catroid-maven-playground, under directory /src/main/java/at/tugraz/ist/catroid/utils/.

Source file: ImageEditing.java

  34 
vote

/** 
 * Scales the bitmap to the specified size.
 * @param bitmap the bitmap to resize
 * @param xSize desired x size
 * @param ySize desired y size
 * @return a new, scaled bitmap
 */
public static Bitmap scaleBitmap(Bitmap bitmap,int xSize,int ySize){
  Matrix matrix=new Matrix();
  float scaleWidth=(((float)xSize) / bitmap.getWidth());
  float scaleHeight=(((float)ySize) / bitmap.getHeight());
  matrix.postScale(scaleWidth,scaleHeight);
  Bitmap newBitmap=Bitmap.createBitmap(bitmap,0,0,bitmap.getWidth(),bitmap.getHeight(),matrix,true);
  return newBitmap;
}
 

Example 3

From project android-cropimage, under directory /src/com/android/camera/.

Source file: CropImage.java

  32 
vote

private Bitmap prepareBitmap(){
  if (mBitmap == null) {
    return null;
  }
  if (mBitmap.getWidth() > 256) {
    mScale=256.0F / mBitmap.getWidth();
  }
  Matrix matrix=new Matrix();
  matrix.setScale(mScale,mScale);
  Bitmap faceBitmap=Bitmap.createBitmap(mBitmap,0,0,mBitmap.getWidth(),mBitmap.getHeight(),matrix,true);
  return faceBitmap;
}
 

Example 4

From project android-gltron, under directory /GlTron/src/com/glTron/Video/.

Source file: GLTexture.java

  32 
vote

private void loadTexture(GL10 gl,Context context,int resource){
  gl.glGenTextures(1,_texID,0);
  Matrix flip=new Matrix();
  flip.postScale(1f,-1f);
  BitmapFactory.Options opts=new BitmapFactory.Options();
  opts.inScaled=false;
  Bitmap temp=BitmapFactory.decodeResource(context.getResources(),resource,opts);
  Bitmap bmp=Bitmap.createBitmap(temp,0,0,temp.getWidth(),temp.getHeight(),flip,true);
  temp.recycle();
  gl.glBindTexture(GL10.GL_TEXTURE_2D,_texID[0]);
  if (boGenMipMap) {
    gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_LINEAR_MIPMAP_NEAREST);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_LINEAR_MIPMAP_NEAREST);
  }
 else {
    gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_LINEAR);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_LINEAR);
  }
  gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_WRAP_S,WrapS);
  gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_WRAP_T,WrapT);
  DebugType=GLUtils.getInternalFormat(bmp);
  if (boGenMipMap) {
    for (int level=0, height=bmp.getHeight(), width=bmp.getWidth(); true; level++) {
      GLUtils.texImage2D(GL10.GL_TEXTURE_2D,level,bmp,0);
      if (height == 1 && width == 1)       break;
      width>>=1;
      height>>=1;
      if (width < 1)       width=1;
      if (height < 1)       height=1;
      Bitmap bmp2=Bitmap.createScaledBitmap(bmp,width,height,true);
      bmp.recycle();
      bmp=bmp2;
    }
  }
 else {
    GLUtils.texImage2D(GL10.GL_TEXTURE_2D,0,bmp,0);
  }
  bmp.recycle();
}
 

Example 5

From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.

Source file: Overlay.java

  32 
vote

/** 
 * Default constructor which must be called by all subclasses.
 */
protected Overlay(){
  super();
  this.overlayCanvas=new Canvas();
  this.matrix=new Matrix();
  this.point=new Point();
  this.positionBeforeDraw=new Point();
  this.positionAfterDraw=new Point();
}
 

Example 6

From project androidquery, under directory /src/com/androidquery/util/.

Source file: RatioDrawable.java

  32 
vote

public RatioDrawable(Resources res,Bitmap bm,ImageView iv,float ratio,float anchor){
  super(res,bm);
  this.ref=new WeakReference<ImageView>(iv);
  this.ratio=ratio;
  this.anchor=anchor;
  iv.setScaleType(ScaleType.MATRIX);
  Matrix m=new Matrix();
  iv.setImageMatrix(m);
  adjust(iv,bm,false);
}
 

Example 7

From project android_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: CropImage.java

  32 
vote

private Bitmap prepareBitmap(){
  if (mBitmap == null) {
    return null;
  }
  if (mBitmap.getWidth() > 256) {
    mScale=256.0F / mBitmap.getWidth();
  }
  Matrix matrix=new Matrix();
  matrix.setScale(mScale,mScale);
  Bitmap faceBitmap=Bitmap.createBitmap(mBitmap,0,0,mBitmap.getWidth(),mBitmap.getHeight(),matrix,true);
  return faceBitmap;
}
 

Example 8

From project android_packages_apps_Gallery2, under directory /gallerycommon/src/com/android/gallery3d/common/.

Source file: BitmapUtils.java

  32 
vote

public static Bitmap rotateBitmap(Bitmap source,int rotation,boolean recycle){
  if (rotation == 0)   return source;
  int w=source.getWidth();
  int h=source.getHeight();
  Matrix m=new Matrix();
  m.postRotate(rotation);
  Bitmap bitmap=Bitmap.createBitmap(source,0,0,w,h,m,true);
  if (recycle)   source.recycle();
  return bitmap;
}
 

Example 9

From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/media/.

Source file: CropImage.java

  32 
vote

private Bitmap prepareBitmap(){
  if (mBitmap == null) {
    return null;
  }
  if (mBitmap.getWidth() > 256) {
    mScale=256.0F / mBitmap.getWidth();
  }
  Matrix matrix=new Matrix();
  matrix.setScale(mScale,mScale);
  Bitmap faceBitmap=Bitmap.createBitmap(mBitmap,0,0,mBitmap.getWidth(),mBitmap.getHeight(),matrix,true);
  return faceBitmap;
}
 

Example 10

From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.

Source file: CropCropImage.java

  32 
vote

private Bitmap prepareBitmap(){
  if (mBitmap == null) {
    return null;
  }
  if (mBitmap.getWidth() > 256) {
    mScale=256.0F / mBitmap.getWidth();
  }
  Matrix matrix=new Matrix();
  matrix.setScale(mScale,mScale);
  Bitmap faceBitmap=Bitmap.createBitmap(mBitmap,0,0,mBitmap.getWidth(),mBitmap.getHeight(),matrix,true);
  return faceBitmap;
}
 

Example 11

From project CHMI, under directory /src/it/sephiroth/android/library/imagezoom/.

Source file: ImageViewTouchBase.java

  32 
vote

protected RectF getBitmapRect(){
  if (mBitmapDisplayed.getBitmap() == null)   return null;
  Matrix m=getImageViewMatrix();
  RectF rect=new RectF(0,0,mBitmapDisplayed.getBitmap().getWidth(),mBitmapDisplayed.getBitmap().getHeight());
  m.mapRect(rect);
  return rect;
}
 

Example 12

From project cow, under directory /libs/ActionBarSherlock/library/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  32 
vote

@Override protected void applyTransformation(float interpolatedTime,Transformation t){
  t.setAlpha(mAlpha);
  final Matrix m=t.getMatrix();
  m.postTranslate(mTranslationX,mTranslationY);
  m.postScale(mScaleX,mScaleY);
}
 

Example 13

From project cropimage, under directory /src/com/droid4you/util/cropimage/.

Source file: CropImage.java

  32 
vote

private Bitmap prepareBitmap(){
  if (mBitmap == null) {
    return null;
  }
  if (mBitmap.getWidth() > 256) {
    mScale=256.0F / mBitmap.getWidth();
  }
  Matrix matrix=new Matrix();
  matrix.setScale(mScale,mScale);
  Bitmap faceBitmap=Bitmap.createBitmap(mBitmap,0,0,mBitmap.getWidth(),mBitmap.getHeight(),matrix,true);
  return faceBitmap;
}
 

Example 14

From project danbo, under directory /src/us/donmai/danbooru/danbo/cropimage/.

Source file: CropImage.java

  32 
vote

private Bitmap prepareBitmap(){
  if (mBitmap == null) {
    return null;
  }
  if (mBitmap.getWidth() > 256) {
    mScale=256.0F / mBitmap.getWidth();
  }
  Matrix matrix=new Matrix();
  matrix.setScale(mScale,mScale);
  Bitmap faceBitmap=Bitmap.createBitmap(mBitmap,0,0,mBitmap.getWidth(),mBitmap.getHeight(),matrix,true);
  return faceBitmap;
}
 

Example 15

From project danbooru-gallery-android, under directory /src/it/sephiroth/android/library/imagezoom/.

Source file: ImageViewTouchBase.java

  32 
vote

public RectF getBitmapRect(){
  if (mBitmapDisplayed == null)   return null;
  Matrix m=getImageViewMatrix();
  RectF rect=new RectF(0,0,mBitmapDisplayed.getWidth(),mBitmapDisplayed.getHeight());
  m.mapRect(rect);
  return rect;
}
 

Example 16

From project droidkit, under directory /src/org/droidkit/image/app/crop/.

Source file: RotateBitmap.java

  32 
vote

public Matrix getRotateMatrix(){
  Matrix matrix=new Matrix();
  if (mRotation != 0) {
    int cx=mBitmap.getWidth() / 2;
    int cy=mBitmap.getHeight() / 2;
    matrix.preTranslate(-cx,-cy);
    matrix.postRotate(mRotation);
    matrix.postTranslate(getWidth() / 2,getHeight() / 2);
  }
  return matrix;
}
 

Example 17

From project Ebento, under directory /src/mobisocial/bento/ebento/util/.

Source file: BitmapHelper.java

  32 
vote

public static Bitmap getResizedBitmap(Bitmap src,int targetWidth,int targetHeight,float degrees){
  int srcWidth=src.getWidth();
  int srcHeight=src.getHeight();
  float scale=getFitScale(targetWidth,targetHeight,srcWidth,srcHeight);
  Matrix matrix=new Matrix();
  matrix.postScale(scale,scale);
  matrix.postRotate(degrees);
  return Bitmap.createBitmap(src,0,0,srcWidth,srcHeight,matrix,true);
}
 

Example 18

From project FlipDroid, under directory /app/src/com/goal98/flipdroid2/view/.

Source file: CubeView.java

  32 
vote

/** 
 * ?????????????????????
 * @param isLR
 * @return
 */
private Bitmap cutTurnBmp(boolean isLR){
  Matrix matrix=new Matrix();
  matrix.preScale(-1,1);
  Bitmap turnBmpBack;
  if (isLR) {
    turnBmpBack=Bitmap.createBitmap(turnBmp,centerX,0,centerX,bHeight,matrix,false);
  }
 else {
    turnBmpBack=Bitmap.createBitmap(turnBmp,0,0,centerX,bHeight,matrix,false);
  }
  return turnBmpBack;
}
 

Example 19

From project Game_3, under directory /android/src/playn/android/.

Source file: AndroidCanvas.java

  32 
vote

@Override public Canvas setTransform(float m11,float m12,float m21,float m22,float dx,float dy){
  Matrix m=new Matrix();
  m.setValues(new float[]{m11,m12,0,m21,0,m22,dx,dy,1});
  canvas.setMatrix(m);
  return this;
}
 

Example 20

From project gast-lib, under directory /library/src/root/gast/image/.

Source file: LogoView.java

  32 
vote

@Override public void onDraw(Canvas c){
  super.onDraw(c);
  if (mImageCameraView != null && mRect != null) {
    Matrix m=mImageCameraView.getImageMatrix();
    if (m != null) {
      RectF rectDraw=new RectF();
      m.mapRect(rectDraw,mRect);
      Paint p=new Paint();
      p.setColor(DRAW_COLOR);
      p.setStyle(Style.STROKE);
      c.drawRect(rectDraw,p);
    }
  }
}
 

Example 21

From project generic-store-for-android, under directory /src/com/wareninja/opensource/common/.

Source file: WareNinjaUtils.java

  32 
vote

public static Bitmap getBitmapWithReflection(Bitmap originalImage){
  final int reflectionGap=4;
  int width=originalImage.getWidth();
  int height=originalImage.getHeight();
  Matrix matrix=new Matrix();
  matrix.preScale(1,-1);
  Bitmap reflectionImage=Bitmap.createBitmap(originalImage,0,height / 2,width,height / 2,matrix,false);
  Bitmap bitmapWithReflection=Bitmap.createBitmap(width,(height + height / 2),Config.ARGB_8888);
  Canvas canvas=new Canvas(bitmapWithReflection);
  canvas.drawBitmap(originalImage,0,0,null);
  Paint deafaultPaint=new Paint();
  canvas.drawRect(0,height,width,height + reflectionGap,deafaultPaint);
  canvas.drawBitmap(reflectionImage,0,height + reflectionGap,null);
  Paint paint=new Paint();
  LinearGradient shader=new LinearGradient(0,originalImage.getHeight(),0,bitmapWithReflection.getHeight() + reflectionGap,0x70ffffff,0x00ffffff,TileMode.CLAMP);
  paint.setShader(shader);
  paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
  canvas.drawRect(0,height,width,bitmapWithReflection.getHeight() + reflectionGap,paint);
  return bitmapWithReflection;
}
 

Example 22

From project gobandroid, under directory /src/org/ligi/gobandroid_hd/ui/.

Source file: GoBoardView.java

  32 
vote

public Bitmap resize_to_screen(Bitmap orig,float x_scale_,float y_scale_){
  Matrix matrix=new Matrix();
  float x_scale, y_scale;
  if (y_scale_ != 0f)   y_scale=(getHeight() * y_scale_) / orig.getHeight();
 else   y_scale=(getWidth() * x_scale_) / orig.getWidth();
  if (x_scale_ != 0f)   x_scale=(getWidth() * x_scale_) / orig.getWidth();
 else   x_scale=(getHeight() * y_scale_) / orig.getHeight();
  matrix.postScale(x_scale,y_scale);
  return Bitmap.createBitmap(orig,0,0,(int)(orig.getWidth()),(int)(orig.getHeight()),matrix,true);
}
 

Example 23

From project God-Save-The-Bag, under directory /src/com/estudio/cheke/game/gstb/.

Source file: SVGParser.java

  32 
vote

private static Matrix parseTransform(String s){
  Matrix matrix=new Matrix();
  while (true) {
    parseTransformItem(s,matrix);
    int rparen=s.indexOf(")");
    if (rparen > 0 && s.length() > rparen + 1) {
      s=s.substring(rparen + 1).replaceFirst("[\\s,]*","");
    }
 else {
      break;
    }
  }
  return matrix;
}
 

Example 24

From project HeLauncher, under directory /src/com/handlerexploit/launcher_reloaded/.

Source file: CellLayout.java

  32 
vote

private void initThumb(int width,int height){
  if (mThumb == null || mThumb.isRecycled())   mThumb=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_4444);
  Matrix matrix=new Matrix();
  matrix.setScale(0.25f,0.25f);
  mThumbCanvas=new Canvas(mThumb);
  mThumbCanvas.concat(matrix);
  mThumbPaint=new Paint();
  mThumbPaint.setDither(true);
  mThumbPaint.setAntiAlias(true);
}
 

Example 25

From project ImageFilterForAndroid, under directory /src/HaoRan/ImageFilter/.

Source file: Image.java

  32 
vote

/** 
 * Method to rotate an image by the specified number of degrees
 * @param rotateDegrees
 */
public void rotate(int rotateDegrees){
  Matrix mtx=new Matrix();
  mtx.postRotate(rotateDegrees);
  image=Bitmap.createBitmap(image,0,0,width,height,mtx,true);
  width=image.getWidth();
  height=image.getHeight();
  updateColorArray();
}
 

Example 26

From project incubator-cordova-android, under directory /framework/src/org/apache/cordova/.

Source file: CameraLauncher.java

  32 
vote

/** 
 * Figure out if the bitmap should be rotated. For instance if the picture was taken in portrait mode
 * @param rotate
 * @param bitmap
 * @return rotated bitmap
 */
private Bitmap getRotatedBitmap(int rotate,Bitmap bitmap,ExifHelper exif){
  Matrix matrix=new Matrix();
  if (rotate == 180) {
    matrix.setRotate(rotate);
  }
 else {
    matrix.setRotate(rotate,(float)bitmap.getWidth() / 2,(float)bitmap.getHeight() / 2);
  }
  bitmap=Bitmap.createBitmap(bitmap,0,0,bitmap.getWidth(),bitmap.getHeight(),matrix,true);
  exif.resetOrientation();
  return bitmap;
}
 

Example 27

From project iPhoroidUI, under directory /src/org/klab/iphoroid/widget/coverflow/.

Source file: CoverFlowImageAdapterBase.java

  32 
vote

/** 
 */
protected Bitmap makeResizedImage(Bitmap src,int width,int height){
  Matrix matrix=new Matrix();
  matrix.preScale(1,-1);
  Bitmap dest=Bitmap.createBitmap(width,height,Config.RGB_565);
  Canvas canvas=new Canvas(dest);
  canvas.drawBitmap(src,new Rect(0,0,src.getWidth(),src.getHeight()),new Rect(0,0,width,height),null);
  return dest;
}
 

Example 28

From project Krypsis, under directory /Android/src/org/krypsis/android/command/photo/.

Source file: TakeAndUploadCommand.java

  32 
vote

/** 
 * Resize the given bitmap to the maximum size. Example: If the given bitmap has a size if 1600x1600 and should be resized to the maximum of 1024x768 then the result will have a size of 768x768. That is because the maximum height is 768 and the scale factor is 0.48
 * @param bitmap The bitmap to resize
 * @param maxWidth The maximum width
 * @param maxHeight The maximum height
 * @return The resized bitmap, or, if the given bitmapsize is smaller, the original reference.
 */
private Bitmap resize(Bitmap bitmap,int maxWidth,int maxHeight){
  final int width=bitmap.getWidth();
  final int height=bitmap.getHeight();
  if (maxWidth >= width && maxHeight >= height) {
    return bitmap;
  }
  final float scale=Math.min(((float)maxWidth) / width,((float)maxHeight) / height);
  Matrix matrix=new Matrix();
  matrix.postScale(scale,scale);
  logger.debug("Use scale factor: " + scale);
  Bitmap resizedBitmap=Bitmap.createBitmap(bitmap,0,0,width,height,matrix,true);
  logger.debug("Bitmap resized from " + width + "x"+ height+ " to "+ resizedBitmap.getWidth()+ "x"+ resizedBitmap.getHeight());
  return resizedBitmap;
}
 

Example 29

From project LigiAndroidCommons, under directory /src/org/ligi/android/common/bitmap/.

Source file: BitmapScaler.java

  32 
vote

public static Bitmap relative2View(View view,Bitmap orig,float x_scale_,float y_scale_){
  Matrix matrix=new Matrix();
  float x_scale, y_scale;
  if (y_scale_ != 0f)   y_scale=(view.getHeight() * y_scale_) / orig.getHeight();
 else   y_scale=(view.getWidth() * x_scale_) / orig.getWidth();
  if (x_scale_ != 0f)   x_scale=(view.getWidth() * x_scale_) / orig.getWidth();
 else   x_scale=(view.getHeight() * y_scale_) / orig.getHeight();
  matrix.postScale(x_scale,y_scale);
  return Bitmap.createBitmap(orig,0,0,orig.getWidth(),orig.getHeight(),matrix,true);
}
 

Example 30

From project maven-android-plugin-samples, under directory /apidemos-android-10/application/src/main/java/com/example/android/apis/graphics/.

Source file: Xfermodes.java

  32 
vote

public SampleView(Context context){
  super(context);
  mSrcB=makeSrc(W,H);
  mDstB=makeDst(W,H);
  Bitmap bm=Bitmap.createBitmap(new int[]{0xFFFFFFFF,0xFFCCCCCC,0xFFCCCCCC,0xFFFFFFFF},2,2,Bitmap.Config.RGB_565);
  mBG=new BitmapShader(bm,Shader.TileMode.REPEAT,Shader.TileMode.REPEAT);
  Matrix m=new Matrix();
  m.setScale(6,6);
  mBG.setLocalMatrix(m);
}
 

Example 31

From project mediautilities, under directory /src/ac/robinson/cropimage/.

Source file: CropImage.java

  32 
vote

private Bitmap prepareBitmap(){
  if (mBitmap == null) {
    return null;
  }
  if (mBitmap.getWidth() > 256) {
    mScale=256.0F / mBitmap.getWidth();
  }
  Matrix matrix=new Matrix();
  matrix.setScale(mScale,mScale);
  Bitmap faceBitmap=Bitmap.createBitmap(mBitmap,0,0,mBitmap.getWidth(),mBitmap.getHeight(),matrix,true);
  return faceBitmap;
}
 

Example 32

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 33

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 34

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 35

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 36

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 37

From project android-bankdroid, under directory /src/com/liato/bankdroid/lockpattern/.

Source file: LockPatternView.java

  31 
vote

private void drawArrow(Canvas canvas,float leftX,float topY,Cell start,Cell end){
  boolean green=mPatternDisplayMode != DisplayMode.Wrong;
  final int endRow=end.row;
  final int startRow=start.row;
  final int endColumn=end.column;
  final int startColumn=start.column;
  final int offsetX=((int)mSquareWidth - mBitmapWidth) / 2;
  final int offsetY=((int)mSquareHeight - mBitmapHeight) / 2;
  Bitmap arrow=green ? mBitmapArrowGreenUp : mBitmapArrowRedUp;
  Matrix matrix=new Matrix();
  final int cellWidth=mBitmapCircleDefault.getWidth();
  final int cellHeight=mBitmapCircleDefault.getHeight();
  final float theta=(float)Math.atan2((double)(endRow - startRow),(double)(endColumn - startColumn));
  final float angle=(float)Math.toDegrees(theta) + 90.0f;
  matrix.setTranslate(leftX + offsetX,topY + offsetY);
  matrix.preRotate(angle,cellWidth / 2.0f,cellHeight / 2.0f);
  matrix.preTranslate((cellWidth - arrow.getWidth()) / 2.0f,0.0f);
  canvas.drawBitmap(arrow,matrix,mPaint);
}
 

Example 38

From project Android-GifStitch, under directory /src/com/phunkosis/gifstitch/helpers/.

Source file: ImageHelper.java

  31 
vote

public static Bitmap getDesirableBitmap(String imgPath,int desiredSize){
  try {
    int scale=getDesirableBitmapSampleSize(imgPath,desiredSize);
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inSampleSize=scale;
    Bitmap originalBitmap=BitmapFactory.decodeFile(imgPath,options);
    int rotation=getExifOrientation(imgPath);
    if (rotation != 0) {
      Matrix matrix=new Matrix();
      matrix.postRotate(rotation);
      Bitmap exifBitmap=Bitmap.createBitmap(originalBitmap,0,0,originalBitmap.getWidth(),originalBitmap.getHeight(),matrix,true);
      originalBitmap.recycle();
      return exifBitmap;
    }
    return originalBitmap;
  }
 catch (  Exception ex) {
    ex.printStackTrace();
  }
catch (  OutOfMemoryError e) {
    e.printStackTrace();
  }
  return null;
}
 

Example 39

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/util/.

Source file: ImageUtilities.java

  31 
vote

private static Bitmap createScaledBitmap(Bitmap src,int dstWidth,int dstHeight,float offset,boolean clipShadow,Paint paint){
  Matrix m;
synchronized (Bitmap.class) {
    m=sScaleMatrix;
    sScaleMatrix=null;
  }
  if (m == null) {
    m=new Matrix();
  }
  final int width=src.getWidth();
  final int height=src.getHeight();
  final float sx=dstWidth / (float)width;
  final float sy=dstHeight / (float)height;
  m.setScale(sx,sy);
  Bitmap b=createBitmap(src,0,0,width,height,m,offset,clipShadow,paint);
synchronized (Bitmap.class) {
    sScaleMatrix=m;
  }
  return b;
}
 

Example 40

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 41

From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/util/.

Source file: ImageUtils.java

  31 
vote

/** 
 * Resizes specific a Bitmap with keeping ratio.
 */
public static Bitmap resizeBitmap(Bitmap drawable,int desireWidth,int desireHeight){
  int width=drawable.getWidth();
  int height=drawable.getHeight();
  if (0 < width && 0 < height && desireWidth < width || desireHeight < height) {
    float scale;
    if (width < height) {
      scale=(float)desireHeight / (float)height;
      if (desireWidth < width * scale) {
        scale=(float)desireWidth / (float)width;
      }
    }
 else {
      scale=(float)desireWidth / (float)width;
    }
    Matrix matrix=new Matrix();
    matrix.postScale(scale,scale);
    Bitmap bitmap=Bitmap.createBitmap(drawable,0,0,width,height,matrix,true);
    Canvas canvas=new Canvas(bitmap);
    canvas.drawBitmap(bitmap,0,0,null);
    drawable=bitmap;
  }
  return drawable;
}
 

Example 42

From project apps-for-android, under directory /LolcatBuilder/src/com/android/lolcat/.

Source file: LolcatView.java

  31 
vote

@Override protected void onDraw(Canvas canvas){
  Log.i(TAG,"onDraw: " + canvas);
  super.onDraw(canvas);
  if (mDragging) {
    Log.i(TAG,"- dragging!  Drawing box at " + mCurrentDragBox);
    Matrix m=getImageMatrix();
    mCurrentDragBoxF.set(mCurrentDragBox);
    m.mapRect(mTransformedDragBoxF,mCurrentDragBoxF);
    mTransformedDragBoxF.offset(getPaddingLeft(),getPaddingTop());
    Paint p=new Paint();
    p.setColor(0xFFFFFFFF);
    p.setStyle(Paint.Style.STROKE);
    p.setStrokeWidth(2f);
    Log.i(TAG,"- Paint: " + p);
    canvas.drawRect(mTransformedDragBoxF,p);
  }
}
 

Example 43

From project CineShowTime-Android, under directory /Libraries/CineShowTime/src/pl/polidea/coverflow/.

Source file: CoverFlow.java

  31 
vote

/** 
 * Transform the Image Bitmap by the Angle passed.
 * @param imageView ImageView the ImageView whose bitmap we want to rotate
 * @param t transformation
 * @param rotationAngle the Angle by which to rotate the Bitmap
 */
private void transformImageBitmap(final ImageView child,final Transformation t,final int rotationAngle){
  mCamera.save();
  final Matrix imageMatrix=t.getMatrix();
  final int height=child.getLayoutParams().height;
  final int width=child.getLayoutParams().width;
  final int rotation=Math.abs(rotationAngle);
  mCamera.translate(0.0f,0.0f,100.0f);
  if (rotation < mMaxRotationAngle) {
    final float zoomAmount=(float)(mMaxZoom + rotation * 1.5);
    mCamera.translate(0.0f,0.0f,zoomAmount);
  }
  mCamera.rotateY(rotationAngle);
  mCamera.getMatrix(imageMatrix);
  imageMatrix.preTranslate(-(width / 2.0f),-(height / 2.0f));
  imageMatrix.postTranslate((width / 2.0f),(height / 2.0f));
  mCamera.restore();
}
 

Example 44

From project Common-Sense-Net-2, under directory /AndroidBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 45

From project cw-omnibus, under directory /external/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 46

From project DeskSMS, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 47

From project dmix, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 48

From project dreamDroid, under directory /libraries/ABS/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 49

From project dungbeetle, under directory /src/edu/stanford/mobisocial/dungbeetle/feed/objects/.

Source file: VideoObj.java

  31 
vote

public static DbObject from(Context context,Uri videoUri) throws IOException {
  ContentResolver cr=context.getContentResolver();
  BitmapFactory.Options options=new BitmapFactory.Options();
  options.inSampleSize=1;
  long videoId=Long.parseLong(videoUri.getLastPathSegment());
  Bitmap curThumb=MediaStore.Video.Thumbnails.getThumbnail(cr,videoId,MediaStore.Video.Thumbnails.MINI_KIND,options);
  int targetSize=200;
  int width=curThumb.getWidth();
  int height=curThumb.getHeight();
  int cropSize=Math.min(width,height);
  float scaleSize=((float)targetSize) / cropSize;
  Matrix matrix=new Matrix();
  matrix.postScale(scaleSize,scaleSize);
  curThumb=Bitmap.createBitmap(curThumb,0,0,width,height,matrix,true);
  JSONObject base=new JSONObject();
  String localIp=ContentCorral.getLocalIpAddress();
  if (localIp != null) {
    try {
      base.put(Contact.ATTR_LAN_IP,localIp);
      base.put(LOCAL_URI,videoUri.toString());
      base.put(MIME_TYPE,cr.getType(videoUri));
    }
 catch (    JSONException e) {
      Log.e(TAG,"impossible json error possible!");
    }
  }
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  curThumb.compress(Bitmap.CompressFormat.JPEG,90,baos);
  byte[] data=baos.toByteArray();
  return from(base,data);
}
 

Example 50

From project examples_2, under directory /SearchView/actionbarsherlock-lib/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 51

From project farebot, under directory /libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 52

From project filemanager, under directory /FileManager/src/org/openintents/filemanager/util/.

Source file: ImageUtils.java

  31 
vote

/** 
 * Resizes specific a Bitmap with keeping ratio.
 */
public static Bitmap resizeBitmap(Bitmap drawable,int desireWidth,int desireHeight){
  int width=drawable.getWidth();
  int height=drawable.getHeight();
  if (0 < width && 0 < height && desireWidth < width || desireHeight < height) {
    float scale;
    if (width < height) {
      scale=(float)desireHeight / (float)height;
      if (desireWidth < width * scale) {
        scale=(float)desireWidth / (float)width;
      }
    }
 else {
      scale=(float)desireWidth / (float)width;
    }
    Matrix matrix=new Matrix();
    matrix.postScale(scale,scale);
    Bitmap bitmap=Bitmap.createBitmap(drawable,0,0,width,height,matrix,true);
    Canvas canvas=new Canvas(bitmap);
    canvas.drawBitmap(bitmap,0,0,null);
    drawable=bitmap;
  }
  return drawable;
}
 

Example 53

From project finch, under directory /libs/JakeWharton-ActionBarSherlock-2eabf25/library/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 54

From project friendica-for-android, under directory /mw-android-friendica-01/src/de/wikilab/android/friendica01/.

Source file: Max.java

  31 
vote

public static void resizeImage(String pathOfInputImage,String pathOfOutputImage,int dstWidth,int dstHeight){
  try {
    int inWidth=0;
    int inHeight=0;
    InputStream in=new FileInputStream(pathOfInputImage);
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inJustDecodeBounds=true;
    BitmapFactory.decodeStream(in,null,options);
    in.close();
    in=null;
    inWidth=options.outWidth;
    inHeight=options.outHeight;
    in=new FileInputStream(pathOfInputImage);
    options=new BitmapFactory.Options();
    options.inSampleSize=Math.max(inWidth / dstWidth,inHeight / dstHeight);
    Bitmap roughBitmap=BitmapFactory.decodeStream(in,null,options);
    Matrix m=new Matrix();
    RectF inRect=new RectF(0,0,roughBitmap.getWidth(),roughBitmap.getHeight());
    RectF outRect=new RectF(0,0,dstWidth,dstHeight);
    m.setRectToRect(inRect,outRect,Matrix.ScaleToFit.CENTER);
    float[] values=new float[9];
    m.getValues(values);
    Bitmap resizedBitmap=Bitmap.createScaledBitmap(roughBitmap,(int)(roughBitmap.getWidth() * values[0]),(int)(roughBitmap.getHeight() * values[4]),true);
    try {
      FileOutputStream out=new FileOutputStream(pathOfOutputImage);
      resizedBitmap.compress(Bitmap.CompressFormat.JPEG,80,out);
    }
 catch (    Exception e) {
      Log.e("Image",e.getMessage(),e);
    }
  }
 catch (  IOException e) {
    Log.e("Image",e.getMessage(),e);
  }
}
 

Example 55

From project GnucashMobile, under directory /com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 56

From project Google-Tasks-Client, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 57

From project HSR-Timetable, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 58

From project ihatovgram, under directory /src/client/android/ihatovgram/src/com/ipuweb/ihatovgram/.

Source file: CameraView.java

  31 
vote

private void data2file(byte[] data,String fileName) throws Exception {
  FileOutputStream out=null;
  try {
    out=new FileOutputStream(fileName);
    Bitmap bitmap=BitmapFactory.decodeByteArray(data,0,data.length);
    int width=bitmap.getWidth();
    int height=bitmap.getHeight();
    Matrix matrix=new Matrix();
    matrix.postRotate(90);
    bitmap=Bitmap.createBitmap(bitmap,0,0,width,height,matrix,true);
    bitmap.compress(CompressFormat.JPEG,100,out);
    out.write(data);
    out.close();
  }
 catch (  Exception e) {
    if (out != null) {
      out.close();
    }
    throw e;
  }
}
 

Example 59

From project iosched_3, under directory /libprojects/abs/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 60

From project IRC-Client, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  31 
vote

private void computeRect(final RectF r,View view){
  final float w=view.getWidth();
  final float h=view.getHeight();
  r.set(0,0,w,h);
  final Matrix m=mTempMatrix;
  m.reset();
  transformMatrix(m,view);
  mTempMatrix.mapRect(r);
  r.offset(view.getLeft(),view.getTop());
  if (r.right < r.left) {
    final float f=r.right;
    r.right=r.left;
    r.left=f;
  }
  if (r.bottom < r.top) {
    final float f=r.top;
    r.top=r.bottom;
    r.bottom=f;
  }
}
 

Example 61

From project jamendo-android, under directory /src/com/teleca/jamendo/activity/.

Source file: AlbumActivity.java

  31 
vote

private void setupTabs(){
  mTabHost=getTabHost();
  Bitmap coverBmp=JamendoApplication.getInstance().getImageCache().get(mAlbum.getImage());
  if (coverBmp == null) {
    coverBmp=JamendoApplication.getInstance().getImageCache().get(mAlbum.getImage().replaceAll("1.100.jpg",mBetterRes));
  }
  if (coverBmp != null) {
    int tabSize=(int)getResources().getDimension(R.dimen.tab_size);
    int newWidth=tabSize;
    int newHeight=tabSize;
    float scaleWidth=((float)newWidth) / coverBmp.getWidth();
    float scaleHeight=((float)newHeight) / coverBmp.getHeight();
    Matrix matrix=new Matrix();
    matrix.postScale(scaleWidth,scaleHeight);
    Bitmap resizedCoverBmp=Bitmap.createBitmap(coverBmp,0,0,coverBmp.getWidth(),coverBmp.getHeight(),matrix,false);
    BitmapDrawable coverDrawable=DrawableAccessor.construct(getResources(),resizedCoverBmp);
    mAlbumTabSpec=mTabHost.newTabSpec("tab1").setIndicator(mAlbum.getName(),coverDrawable).setContent(R.id.TabTracks);
  }
 else {
    mAlbumTabSpec=mTabHost.newTabSpec("tab1").setIndicator(mAlbum.getName(),getResources().getDrawable(R.drawable.tab_no_cd)).setContent(R.id.TabTracks);
  }
  mReviewsTabSpec=mTabHost.newTabSpec("tab1").setIndicator(getString(R.string.review),getResources().getDrawable(R.drawable.tab_review)).setContent(R.id.TabReviews);
  mTabHost.addTab(mAlbumTabSpec);
  mTabHost.addTab(mReviewsTabSpec);
}
 

Example 62

From project Juggernaut_SystemUI, under directory /src/com/android/systemui/util/.

Source file: BitmapUtil.java

  31 
vote

public static Bitmap getThumbnail(ContentResolver contentResolver,long id){
  Cursor cursor=contentResolver.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,new String[]{MediaStore.Images.Media.DATA},MediaStore.Images.Media._ID + "=?",new String[]{String.valueOf(id)},null);
  if (cursor != null && cursor.getCount() > 0) {
    cursor.moveToFirst();
    String filepath=cursor.getString(0);
    cursor.close();
    int rotation=0;
    try {
      ExifInterface exifInterface=new ExifInterface(filepath);
      int exifRotation=exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,ExifInterface.ORIENTATION_UNDEFINED);
      if (exifRotation != ExifInterface.ORIENTATION_UNDEFINED) {
switch (exifRotation) {
case ExifInterface.ORIENTATION_ROTATE_180:
          rotation=180;
        break;
case ExifInterface.ORIENTATION_ROTATE_270:
      rotation=270;
    break;
case ExifInterface.ORIENTATION_ROTATE_90:
  rotation=90;
break;
}
}
}
 catch (IOException e) {
}
Bitmap bitmap=MediaStore.Images.Thumbnails.getThumbnail(contentResolver,id,MediaStore.Images.Thumbnails.MINI_KIND,null);
if (rotation != 0) {
Matrix matrix=new Matrix();
matrix.setRotate(rotation);
bitmap=Bitmap.createBitmap(bitmap,0,0,bitmap.getWidth(),bitmap.getHeight(),matrix,true);
}
return bitmap;
}
 else {
return null;
}
}
 

Example 63

From project lastfm-android, under directory /app/src/fm/last/android/utils/.

Source file: Rotate3dAnimation.java

  31 
vote

@Override protected void applyTransformation(float interpolatedTime,Transformation t){
  final float fromDegrees=mFromDegrees;
  float degrees=fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime);
  final float centerX=mCenterX;
  final float centerY=mCenterY;
  final Camera camera=mCamera;
  final Matrix matrix=t.getMatrix();
  camera.save();
  if (mReverse) {
    camera.translate(0.0f,0.0f,mDepthZ * interpolatedTime);
  }
 else {
    camera.translate(0.0f,0.0f,mDepthZ * (1.0f - interpolatedTime));
  }
  camera.rotateY(degrees);
  camera.getMatrix(matrix);
  camera.restore();
  matrix.preTranslate(-centerX,-centerY);
  matrix.postTranslate(centerX,centerY);
}
 

Example 64

From project liquidroid, under directory /src/liqui/droid/util/.

Source file: MemberImage.java

  31 
vote

Bitmap getdMemberImage(String memberId,String type,int w,int h){
  Uri CONTENT_URL=Uri.parse("content://liqui.droid.db/member_images").buildUpon().appendQueryParameter("db",mApiDB).build();
  Cursor c=mContext.getContentResolver().query(CONTENT_URL,null,"member_id = ? AND image_type = ?",new String[]{memberId,type},null);
  if (c != null && c.getCount() == 1) {
    c.moveToFirst();
    Member.Image mi=DB2Schema.fillMemberImage(c);
    InputStream inputStream;
    try {
      inputStream=new Base64.InputStream(new ByteArrayInputStream(mi.data.getBytes()));
      final Bitmap bitmap=BitmapFactory.decodeStream(new BufferedInputStream(inputStream));
      int width=bitmap.getWidth();
      int height=bitmap.getHeight();
      float scaleWidth=((float)w) / width;
      float scaleHeight=((float)h) / height;
      Matrix matrix=new Matrix();
      matrix.postScale(scaleWidth,scaleHeight);
      Bitmap resizedBitmap=Bitmap.createBitmap(bitmap,0,0,width,height,matrix,false);
      if (inputStream != null) {
        inputStream.close();
      }
      return resizedBitmap;
    }
 catch (    Exception e) {
      Log.w("MemberImage","Error while retrieving bitmap from member_id: " + memberId + " type: "+ type);
    }
 finally {
    }
  }
 else {
    return BitmapFactory.decodeResource(mContext.getResources(),R.drawable.gravatar);
  }
  return null;
}
 

Example 65

From project Locast-Android, under directory /src/android/media/.

Source file: ThumbnailUtil.java

  31 
vote

public static Bitmap rotate(Bitmap b,int degrees){
  if (degrees != 0 && b != null) {
    final Matrix m=new Matrix();
    m.setRotate(degrees,(float)b.getWidth() / 2,(float)b.getHeight() / 2);
    try {
      final Bitmap b2=Bitmap.createBitmap(b,0,0,b.getWidth(),b.getHeight(),m,true);
      if (b != b2) {
        b.recycle();
        b=b2;
      }
    }
 catch (    final OutOfMemoryError ex) {
    }
  }
  return b;
}
 

Example 66

From project androidTileMapEditor_1, under directory /src/it/sineo/android/tileMapEditor/.

Source file: TiledMapView.java

  30 
vote

public void setTile(int row,int column,String path,byte angle){
  if (path != null) {
    try {
      InputStream is=null;
      if (path.startsWith("assets:")) {
        is=context.getAssets().open(path.substring(7));
      }
      Bitmap source=BitmapFactory.decodeStream(is);
      Bitmap scaled=Bitmap.createScaledBitmap(source,tileSize,tileSize,true);
      tileMap.tileBitmaps[row][column]=scaled;
      tileMap.tilePaths[row][column]=path;
      tileMap.tileAngles[row][column]=angle;
      tileMap.tileMatrices[row][column]=new Matrix();
      source.recycle();
    }
 catch (    IOException ioex) {
      Toast.makeText(context,"Unable to load tile " + path,Toast.LENGTH_SHORT).show();
    }
  }
 else {
    if (tileMap.tileBitmaps[row][column] != null) {
      tileMap.tileBitmaps[row][column].recycle();
    }
    tileMap.tileBitmaps[row][column]=null;
    tileMap.tilePaths[row][column]=null;
    tileMap.tileAngles[row][column]=0;
    tileMap.tileMatrices[row][column]=null;
  }
  invalidate();
}
 

Example 67

From project connectbot, under directory /src/sk/vx/connectbot/.

Source file: TerminalView.java

  30 
vote

public TerminalView(Context context,TerminalBridge bridge){
  super(context);
  this.context=context;
  this.bridge=bridge;
  paint=new Paint();
  setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
  setFocusable(true);
  setFocusableInTouchMode(true);
  cursorPaint=new Paint();
  cursorPaint.setColor(bridge.color[bridge.defaultFg]);
  cursorPaint.setXfermode(new PixelXorXfermode(bridge.color[bridge.defaultBg]));
  cursorPaint.setAntiAlias(true);
  cursorStrokePaint=new Paint(cursorPaint);
  cursorStrokePaint.setStrokeWidth(0.1f);
  cursorStrokePaint.setStyle(Paint.Style.STROKE);
  shiftCursor=new Path();
  shiftCursor.lineTo(0.5f,0.33f);
  shiftCursor.lineTo(1.0f,0.0f);
  altCursor=new Path();
  altCursor.moveTo(0.0f,1.0f);
  altCursor.lineTo(0.5f,0.66f);
  altCursor.lineTo(1.0f,1.0f);
  ctrlCursor=new Path();
  ctrlCursor.moveTo(0.0f,0.25f);
  ctrlCursor.lineTo(1.0f,0.5f);
  ctrlCursor.lineTo(0.0f,0.75f);
  tempSrc=new RectF();
  tempSrc.set(0.0f,0.0f,1.0f,1.0f);
  tempDst=new RectF();
  scaleMatrix=new Matrix();
  bridge.addFontSizeChangedListener(this);
  setOnKeyListener(bridge.getKeyHandler());
  mAccessibilityBuffer=new StringBuffer();
  new AccessibilityStateTester().execute((Void)null);
}
 

Example 68

From project gesture-imageview, under directory /main/src/com/polites/android/.

Source file: GestureImageView.java

  29 
vote

@Override public Matrix getImageMatrix(){
  if (strict) {
    throw new UnsupportedOperationException("Not supported");
  }
  return super.getImageMatrix();
}
 

Example 69

From project Hax-Launcher, under directory /src/com/t3hh4xx0r/haxlauncher/.

Source file: Workspace.java

  29 
vote

void mapPointFromSelfToChild(View v,float[] xy,Matrix cachedInverseMatrix){
  if (cachedInverseMatrix == null) {
    v.getMatrix().invert(mTempInverseMatrix);
    cachedInverseMatrix=mTempInverseMatrix;
  }
  xy[0]=xy[0] + computeHorizontalScrollOffset() - v.getLeft();
  xy[1]=xy[1] + computeVerticalScrollOffset() - v.getTop();
  cachedInverseMatrix.mapPoints(xy);
}
 

Example 70

From project kevoree-library, under directory /android/org.kevoree.library.android.osmdroid/src/main/java/org/osmdroid/views/overlay/.

Source file: MyLocationOverlay.java

  29 
vote

protected void drawMyLocation(final Canvas canvas,final MapView mapView,final Location lastFix,final GeoPoint myLocation){
  final Projection pj=mapView.getProjection();
  pj.toMapPixels(mMyLocation,mMapCoords);
  if (mDrawAccuracyEnabled) {
    final float radius=lastFix.getAccuracy() / (float)TileSystem.GroundResolution(lastFix.getLatitude(),mapView.getZoomLevel());
    mCirclePaint.setAlpha(50);
    mCirclePaint.setStyle(Style.FILL);
    canvas.drawCircle(mMapCoords.x,mMapCoords.y,radius,mCirclePaint);
    mCirclePaint.setAlpha(150);
    mCirclePaint.setStyle(Style.STROKE);
    canvas.drawCircle(mMapCoords.x,mMapCoords.y,radius,mCirclePaint);
  }
  canvas.getMatrix(mMatrix);
  mMatrix.getValues(mMatrixValues);
  if (DEBUGMODE) {
    final float tx=(-mMatrixValues[Matrix.MTRANS_X] + 20) / mMatrixValues[Matrix.MSCALE_X];
    final float ty=(-mMatrixValues[Matrix.MTRANS_Y] + 90) / mMatrixValues[Matrix.MSCALE_Y];
    canvas.drawText("Lat: " + lastFix.getLatitude(),tx,ty + 5,mPaint);
    canvas.drawText("Lon: " + lastFix.getLongitude(),tx,ty + 20,mPaint);
    canvas.drawText("Alt: " + lastFix.getAltitude(),tx,ty + 35,mPaint);
    canvas.drawText("Acc: " + lastFix.getAccuracy(),tx,ty + 50,mPaint);
  }
  if (lastFix.hasBearing()) {
    directionRotater.setRotate(lastFix.getBearing(),DIRECTION_ARROW_CENTER_X,DIRECTION_ARROW_CENTER_Y);
    directionRotater.postTranslate(-DIRECTION_ARROW_CENTER_X,-DIRECTION_ARROW_CENTER_Y);
    directionRotater.postScale(1 / mMatrixValues[Matrix.MSCALE_X],1 / mMatrixValues[Matrix.MSCALE_Y]);
    directionRotater.postTranslate(mMapCoords.x,mMapCoords.y);
    canvas.drawBitmap(DIRECTION_ARROW,directionRotater,mPaint);
  }
 else {
    directionRotater.setTranslate(-PERSON_HOTSPOT.x,-PERSON_HOTSPOT.y);
    directionRotater.postScale(1 / mMatrixValues[Matrix.MSCALE_X],1 / mMatrixValues[Matrix.MSCALE_Y]);
    directionRotater.postTranslate(mMapCoords.x,mMapCoords.y);
    canvas.drawBitmap(PERSON_ICON,directionRotater,mPaint);
  }
}