项目:PicShow-zhaipin
文件:PhotoViewAttacher.java
@Override
public boolean setdisplayMatrix(Matrix finalMatrix) {
if (finalMatrix == null)
throw new IllegalArgumentException("Matrix cannot be null");
ImageView imageView = getimageView();
if (null == imageView)
return false;
if (null == imageView.getDrawable())
return false;
mSuppMatrix.set(finalMatrix);
setimageViewMatrix(getDrawMatrix());
checkMatrixBounds();
return true;
}
项目:ultrasonic
文件:RotateLoadingLayout.java
public RotateLoadingLayout(Context context,Mode mode,Orientation scrollDirection,TypedArray attrs) {
super(context,mode,scrollDirection,attrs);
mRotateDrawableWhilePulling = attrs.getBoolean(R.styleable.PullToRefresh_ptrRotateDrawableWhilePulling,true);
mHeaderImage.setScaleType(ScaleType.MATRIX);
mHeaderImageMatrix = new Matrix();
mHeaderImage.setimageMatrix(mHeaderImageMatrix);
mRotateAnimation = new RotateAnimation(0,720,Animation.RELATIVE_TO_SELF,0.5f,0.5f);
mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION);
mRotateAnimation.setRepeatCount(Animation.INFINITE);
mRotateAnimation.setRepeatMode(Animation.RESTART);
}
public void onPreviewSizeChosen(final Size size,final int rotation) {
previewWidth = size.getWidth();
previewHeight = size.getHeight();
final display display = getwindowManager().getDefaultdisplay();
final int screenorientation = display.getRotation();
LOGGER.i("Sensor orientation: %d,Screen orientation: %d",rotation,screenorientation);
sensorOrientation = rotation + screenorientation;
LOGGER.i("Initializing at size %dx%d",previewWidth,previewHeight);
rgbBytes = new int[previewWidth * previewHeight];
rgbFrameBitmap = Bitmap.createBitmap(previewWidth,previewHeight,Bitmap.Config.ARGB_8888);
croppedBitmap = Bitmap.createBitmap(INPUT_SIZE,INPUT_SIZE,Bitmap.Config.ARGB_8888);
frametoCropTransform =
ImageUtils.getTransformationMatrix(previewWidth,sensorOrientation,MAINTAIN_ASPECT);
Matrix cropToFrameTransform = new Matrix();
frametoCropTransform.invert(cropToFrameTransform);
yuvBytes = new byte[3][];
}
项目:android-image-classification
文件:CameraConnectionFragment.java
/**
* Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
* This method should be called after the camera preview size is determined in
* setUpCameraOutputs and also the size of `mTextureView` is fixed.
*
* @param viewWidth The width of `mTextureView`
* @param viewHeight The height of `mTextureView`
*/
private void configureTransform(final int viewWidth,final int viewHeight) {
final Activity activity = getActivity();
if (null == textureView || null == previewSize || null == activity) {
return;
}
final int rotation = activity.getwindowManager().getDefaultdisplay().getRotation();
final Matrix matrix = new Matrix();
final RectF viewRect = new RectF(0,viewWidth,viewHeight);
final RectF bufferRect = new RectF(0,previewSize.getHeight(),previewSize.getWidth());
final float centerX = viewRect.centerX();
final float centerY = viewRect.centerY();
if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
bufferRect.offset(centerX - bufferRect.centerX(),centerY - bufferRect.centerY());
matrix.setRectToRect(viewRect,bufferRect,Matrix.ScaletoFit.FILL);
final float scale =
Math.max(
(float) viewHeight / previewSize.getHeight(),(float) viewWidth / previewSize.getWidth());
matrix.postScale(scale,scale,centerX,centerY);
matrix.postRotate(90 * (rotation - 2),centerY);
} else if (Surface.ROTATION_180 == rotation) {
matrix.postRotate(180,centerY);
}
textureView.setTransform(matrix);
}
项目:FancyView
文件:RYBDrawStrategyStateTwo.java
@Override
public void drawIcon(Canvas canvas,float fraction,Drawable drawable,int colorOfIcon,WidthAndHeightOfView widthAndHeightOfView) {
int centerX = widthAndHeightOfView.getWidth() / 2;
int centerY = widthAndHeightOfView.getHeight() / 2 - 150;
canvas.save();
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
float newFraction = (fraction - 0.65f) / 0.35f;
paint.setColor(Color.parseColor("#e53935"));
canvas.drawCircle(centerX,centerY - 50,100 * (1 - newFraction),paint);
paint.setColor(Color.parseColor("#fdd835"));
canvas.drawCircle(centerX -35,centerY + 35,paint);
paint.setColor(Color.parseColor("#1e88e5"));
canvas.drawCircle(centerX + 35,paint);
canvas.restore();
canvas.save();
Path path = new Path();
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
Matrix matrix = new Matrix();
matrix.postScale(1.7f,1.7f,centerY);
canvas.concat(matrix);
path.addCircle(centerX,centerY,bitmap.getHeight() * 1.5f * newFraction,Path.Direction.CW);
canvas.clipPath(path);
canvas.drawBitmap(bitmap,centerX - bitmap.getWidth() / 2,centerY - bitmap.getHeight() / 2,paint);
canvas.restore();
}
项目:shareNote
文件:Rotate3dAnimation.java
@Override
protected void applyTransformation(float interpolatedTime,Transformation t) {
final float fromdegrees = mFromdegrees;
float degrees = fromdegrees + ((mTodegrees - fromdegrees) * interpolatedTime);
final Matrix matrix = t.getMatrix();
mCamera.save();
switch (mRollType) {
case ROLL_BY_X:
mCamera.rotateX(degrees);
break;
case ROLL_BY_Y:
mCamera.rotateY(degrees);
break;
case ROLL_BY_Z:
mCamera.rotateZ(degrees);
break;
}
mCamera.getMatrix(matrix);
mCamera.restore();
matrix.preTranslate(-mPivotX,-mPivotY);
matrix.postTranslate(mPivotX,mPivotY);
}
项目:XERUNG
文件:ImageViewTouchBase.java
protected void zoomOut(float rate) {
if (bitmapdisplayed.getBitmap() == null) {
return;
}
float cx = getWidth() / 2F;
float cy = getHeight() / 2F;
// Zoom out to at most 1x
Matrix tmp = new Matrix(suppMatrix);
tmp.postScale(1F / rate,1F / rate,cx,cy);
if (getScale(tmp) < 1F) {
suppMatrix.setScale(1F,1F,cy);
} else {
suppMatrix.postScale(1F / rate,cy);
}
setimageMatrix(getimageViewMatrix());
center();
}
项目:Zoomable
文件:DefaultZoomableController.java
/**
* Limits the translation so that there are no empty spaces on the sides if possible.
*
* <p> The image is attempted to be centered within the view bounds if the transformed image is
* smaller. There will be no empty spaces within the view bounds if the transformed image is
* bigger. This applies to each dimension (horizontal and vertical) independently.
*
* @param limitTypes whether to limit translation along the specific axis.
* @return whether limiting has been applied or not
*/
private boolean limitTranslation(Matrix transform,@LimitFlag int limitTypes) {
if (!shouldLimit(limitTypes,LIMIT_TRANSLATION_X | LIMIT_TRANSLATION_Y)) {
return false;
}
RectF b = mTempRect;
b.set(mImageBounds);
transform.mapRect(b);
float offsetLeft = shouldLimit(limitTypes,LIMIT_TRANSLATION_X) ?
getoffset(b.left,b.right,mViewBounds.left,mViewBounds.right,mImageBounds.centerX()) : 0;
float offsetTop = shouldLimit(limitTypes,LIMIT_TRANSLATION_Y) ?
getoffset(b.top,b.bottom,mViewBounds.top,mViewBounds.bottom,mImageBounds.centerY()) : 0;
if (offsetLeft != 0 || offsetTop != 0) {
transform.postTranslate(offsetLeft,offsetTop);
return true;
}
return false;
}
项目:AppRTC-Android
文件:VideoFrameDrawer.java
/**
* Draws a VideoFrame.TextureBuffer. Calls either drawer.drawoes or drawer.drawRgb
* depending on the type of the buffer. You can supply an additional render matrix. This is
* used multiplied together with the transformation matrix of the frame. (M = renderMatrix *
* transformationMatrix)
*/
static void drawTexture(RendererCommon.GlDrawer drawer,VideoFrame.TextureBuffer buffer,Matrix renderMatrix,int frameWidth,int frameHeight,int viewportX,int viewportY,int viewportWidth,int viewportHeight) {
Matrix finalMatrix = new Matrix(buffer.getTransformMatrix());
finalMatrix.preConcat(renderMatrix);
float[] finalGlMatrix = RendererCommon.convertMatrixFromAndroidGraphicsMatrix(finalMatrix);
switch (buffer.getType()) {
case OES:
drawer.drawoes(buffer.getTextureId(),finalGlMatrix,frameWidth,frameHeight,viewportX,viewportY,viewportWidth,viewportHeight);
break;
case RGB:
drawer.drawRgb(buffer.getTextureId(),viewportHeight);
break;
default:
throw new RuntimeException("UnkNown texture type.");
}
}
项目:JinsMemeBRIDGE-Android
文件:Camera2BasicFragment.java
/**
* Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
* This method should be called after the camera preview size is determined in
* setUpCameraOutputs and also the size of `mTextureView` is fixed.
*
* @param viewWidth The width of `mTextureView`
* @param viewHeight The height of `mTextureView`
*/
private void configureTransform(int viewWidth,int viewHeight) {
Activity activity = getActivity();
if (null == mTextureView || null == mPreviewSize || null == activity) {
return;
}
int rotation = activity.getwindowManager().getDefaultdisplay().getRotation();
Matrix matrix = new Matrix();
RectF viewRect = new RectF(0,viewHeight);
RectF bufferRect = new RectF(0,mPreviewSize.getHeight(),mPreviewSize.getWidth());
float centerX = viewRect.centerX();
float centerY = viewRect.centerY();
if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
bufferRect.offset(centerX - bufferRect.centerX(),centerY - bufferRect.centerY());
matrix.setRectToRect(viewRect,Matrix.ScaletoFit.FILL);
float scale = Math.max(
(float) viewHeight / mPreviewSize.getHeight(),(float) viewWidth / mPreviewSize.getWidth());
matrix.postScale(scale,centerY);
matrix.postRotate(90 * (rotation - 2),centerY);
} else if (Surface.ROTATION_180 == rotation) {
matrix.postRotate(180,centerY);
}
mTextureView.setTransform(matrix);
}
项目:chat-sdk-android-push-firebase
文件:ImageUtils.java
public static Bitmap scaleImage(Bitmap bitmap,int BoxSize){
if (BoxSize == 0)
return null;
// Determine how much to scale: the dimension requiring less scaling is
// closer to the its side. This way the image always stays inside your
// bounding Box AND either x/y axis touches it.
float xScale = ((float) BoxSize) / bitmap.getWidth();
float yScale = ((float) BoxSize) / bitmap.getHeight();
float scale = (xScale <= yScale) ? xScale : yScale;
// Create a matrix for the scaling and add the scaling data
Matrix matrix = new Matrix();
matrix.postScale(scale,scale);
// Create a new bitmap and convert it to a format understood by the ImageView
return Bitmap.createBitmap(bitmap,bitmap.getWidth(),bitmap.getHeight(),matrix,true);
}
项目:android-titanium-imagecropper
文件:BitmapUtils.java
/**
* Rotate the given bitmap by the given degrees.<br>
* New bitmap is created and the old one is recycled.
*/
private static Bitmap rotateAndFlipBitmapInt(
Bitmap bitmap,int degrees,boolean flipHorizontally,boolean flipVertically) {
if (degrees > 0 || flipHorizontally || flipVertically) {
Matrix matrix = new Matrix();
matrix.setRotate(degrees);
matrix.postScale(flipHorizontally ? -1 : 1,flipVertically ? -1 : 1);
Bitmap newBitmap =
Bitmap.createBitmap(bitmap,false);
if (newBitmap != bitmap) {
bitmap.recycle();
}
return newBitmap;
} else {
return bitmap;
}
}
项目:CommonsLab
文件:Camera2VideoFragment.java
/**
* Configures the necessary {@link Matrix} transformation to `mTextureView`.
* This method should not to be called until the camera preview size is determined in
* openCamera,or until the size of `mTextureView` is fixed.
*
* @param viewWidth The width of `mTextureView`
* @param viewHeight The height of `mTextureView`
*/
private void configureTransform(int viewWidth,centerY);
}
mTextureView.setTransform(matrix);
}
项目:smart-lens
文件:Camera2Api.java
/**
* Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
* This method should be called after the camera preview size is determined in
* setUpCameraOutputs and also the size of `mTextureView` is fixed.
*
* @param viewWidth The width of `mTextureView`
* @param viewHeight The height of `mTextureView`
*/
private void configureTransform(final int viewWidth,final int viewHeight) {
if (mPreviewSize == null) return;
final int rotation = mActivity.getwindowManager().getDefaultdisplay().getRotation();
final Matrix matrix = new Matrix();
final RectF viewRect = new RectF(0,viewHeight);
final RectF bufferRect = new RectF(0,mPreviewSize.getWidth());
final float centerX = viewRect.centerX();
final float centerY = viewRect.centerY();
if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
bufferRect.offset(centerX - bufferRect.centerX(),Matrix.ScaletoFit.FILL);
final float scale = Math.max((float) viewHeight / mPreviewSize.getHeight(),centerY);
}
mAutoFitTextureView.setTransform(matrix);
}
项目:Image-Detection-Samples
文件:FDCamera2Presenter.java
/**
* Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
* This method should be called after the camera preview size is determined in
* setUpCameraOutputs and also the size of `mTextureView` is fixed.
*
* @param viewWidth The width of `mTextureView`
* @param viewHeight The height of `mTextureView`
*/
private void configureTransform(int viewWidth,int viewHeight) {
if (isViewAvailable()) {
if (null == activityView.getTextureView()) {
return;
}
int rotation = activityView.getwindowManager().getDefaultdisplay().getRotation();
Matrix matrix = new Matrix();
RectF viewRect = new RectF(0,viewHeight);
RectF bufferRect = new RectF(0,previewSize.getWidth());
float centerX = viewRect.centerX();
float centerY = viewRect.centerY();
if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
bufferRect.offset(centerX - bufferRect.centerX(),centerY - bufferRect.centerY());
matrix.setRectToRect(viewRect,Matrix.ScaletoFit.FILL);
float scale = Math.max(
(float) viewHeight / previewSize.getHeight(),(float) viewWidth / previewSize.getWidth());
matrix.postScale(scale,centerY);
matrix.postRotate(90 * (rotation - 2),centerY);
} else if (Surface.ROTATION_180 == rotation) {
matrix.postRotate(180,centerY);
}
activityView.getTextureView().setTransform(matrix);
}
}
项目:microMathematics
文件:SVGAndroidRenderer.java
private void popLayer(SvgElement obj) {
// If this is masked content,apply the mask Now
if (state.style.mask != null && state.directRendering) {
// The masked content has been drawn,Now we have to render the mask
// to a separate canvas
SVG.Svgobject ref = document.resolveIRI(state.style.mask);
duplicateCanvas();
renderMask((SVG.Mask) ref,obj);
Bitmap maskedContent = processMaskBitmaps();
// Retrieve the real canvas
canvas = canvasstack.pop();
canvas.save();
// Reset the canvas matrix so that we can draw the maskedContent
// exactly over the top of the root bitmap
canvas.setMatrix(new Matrix());
canvas.drawBitmap(maskedContent,state.fillPaint);
maskedContent.recycle();
canvas.restore();
}
statePop();
}
项目:AI_Calorie_Counter_Demo
文件:CameraConnectionFragment.java
/**
* Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
* This method should be called after the camera preview size is determined in
* setUpCameraOutputs and also the size of `mTextureView` is fixed.
*
* @param viewWidth The width of `mTextureView`
* @param viewHeight The height of `mTextureView`
*/
private void configureTransform(final int viewWidth,centerY);
}
textureView.setTransform(matrix);
}
项目:MaterialOCR
文件:ViewGroupUtilsHoneycomb.java
static void offsetDescendantMatrix(ViewParent target,View view,Matrix m) {
final ViewParent parent = view.getParent();
if (parent instanceof View && parent != target) {
final View vp = (View) parent;
offsetDescendantMatrix(target,vp,m);
m.preTranslate(-vp.getScrollX(),-vp.getScrollY());
}
m.preTranslate(view.getLeft(),view.getTop());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
if (!view.getMatrix().isIdentity()) {
m.preConcat(view.getMatrix());
}
}
}
项目:financisto1-holo
文件:ThumbnailUtil.java
/**
* Creates a centered bitmap of the desired size.
* @param source
* @param recycle whether we want to recycle the input
*/
public static Bitmap extractMiniThumb(
Bitmap source,int width,int height,boolean recycle) {
if (source == null) {
return null;
}
float scale;
if (source.getWidth() < source.getHeight()) {
scale = width / (float) source.getWidth();
} else {
scale = height / (float) source.getHeight();
}
Matrix matrix = new Matrix();
matrix.setScale(scale,scale);
Bitmap miniThumbnail = transform(matrix,source,width,height,true,recycle);
return miniThumbnail;
}
项目:godlibrary
文件:PinchImageView.java
/**
* 执行当前outerMatrix到指定outerMatrix渐变的动画
*
* 调用此方法会停止正在进行中的手势以及手势动画.
* 当duration为0时,outerMatrix值会被立即设置而不会启动动画.
*
* @param endMatrix 动画目标矩阵
* @param duration 动画持续时间
*
* @see #getouterMatrix(Matrix)
*/
public void outerMatrixTo(Matrix endMatrix,long duration) {
if (endMatrix == null) {
return;
}
//将手势设置为PINCH_MODE_FREE将停止后续手势的触发
mPinchMode = PINCH_MODE_FREE;
//停止所有正在进行的动画
cancelAllAnimator();
//如果时间不合法立即执行结果
if (duration <= 0) {
mOuterMatrix.set(endMatrix);
dispatchOuterMatrixChanged();
invalidate();
} else {
//创建矩阵变化动画
mScaleAnimator = new ScaleAnimator(mOuterMatrix,endMatrix,duration);
mScaleAnimator.start();
}
}
项目:react-native-webgl-view-shot
文件:RNWebGLTextureView.java
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,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,bitmap,0);
this.attachTexture(textures[0]);
}
项目:tiny
文件:BitmapCompressor.java
private static Bitmap matrixCompress(Bitmap bitmap,int baseline,boolean recycle) {
if (bitmap == null)
return null;
int bitmapWidth = bitmap.getWidth();
int bitmapHeight = bitmap.getHeight();
int maxValue = Math.max(bitmapWidth,bitmapHeight);
if (maxValue > baseline) {
Matrix matrix = new Matrix();
float rate = (float) baseline / (float) maxValue;
matrix.postScale(rate,rate);
Bitmap result = Bitmap.createBitmap(bitmap,bitmapWidth,bitmapHeight,true);
if (recycle) {
bitmap.recycle();
bitmap = null;
}
return result;
} else {
return bitmap;
}
}
项目:FastAndroid
文件:CompressEngine.java
private Bitmap rotatingImage(Bitmap bitmap) {
if (srcExif == null) return bitmap;
Matrix matrix = new Matrix();
int angle = 0;
int orientation = srcExif.getAttributeInt(ExifInterface.TAG_ORIENTATION,ExifInterface.ORIENTATION_norMAL);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
angle = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
angle = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
angle = 270;
break;
}
matrix.postRotate(angle);
return Bitmap.createBitmap(bitmap,true);
}
项目:SweepRobot
文件:PinchImageView.java
/**
* 对图片按照一些手势信息进行缩放
*
* @param scaleCenter mScaleCenter
* @param scaleBase mScaleBase
* @param distance 手指两点之间距离
* @param lineCenter 手指两点之间中点
*
* @see #mScaleCenter
* @see #mScaleBase
*/
private void scaleAndRotate(PointF scaleCenter,float scaleBase,float distance,PointF lineCenter,float degree) {
if (!isReady()) {
return;
}
//计算图片从fit center状态到目标状态的缩放比例
float scale = scaleBase * distance;
Matrix matrix = MathUtils.matrixTake();
//按照图片缩放中心缩放,并且让缩放中心在缩放点中点上
matrix.postScale(scale,scaleCenter.x,scaleCenter.y);
//按照图片缩放中心旋转,并且让缩放中心在缩放点中点上
matrix.postRotate(degree,scaleCenter.y);
//让图片的缩放中点跟随手指缩放中点
matrix.postTranslate(lineCenter.x - scaleCenter.x,lineCenter.y - scaleCenter.y);
//应用变换
mOuterMatrix.set(matrix);
MathUtils.matrixGiven(matrix);
dispatchOuterMatrixChanged();
//重绘
invalidate();
}
项目:GitHub
文件:PhoenixHeader.java
private void initView(Context context,AttributeSet attrs) {
mMatrix = new Matrix();
DensityUtil density = new DensityUtil();
mSunSize = density.dip2px(40);
setupAnimation();
setupPathsDrawable();
setMinimumHeight(density.dip2px(100));
TypedArray ta = context.obtainStyledAttributes(attrs,R.styleable.PhoenixHeader);
int primaryColor = ta.getColor(R.styleable.PhoenixHeader_PHPrimaryColor,0);
int accentColor = ta.getColor(R.styleable.PhoenixHeader_phAccentColor,0);
if (primaryColor != 0) {
setBackgroundColor(primaryColor);
if (accentColor != 0) {
mDrawableSky.parserColors(primaryColor,accentColor);
} else {
mDrawableSky.parserColors(primaryColor);
}
}
ta.recycle();
}
项目:habpanelviewer
文件:MotionDetectorCamera2.java
private void configureTransform(TextureView textureView) {
if (null == textureView || null == mPreviewSize || null == mActivity) {
return;
}
int rotation = mActivity.getwindowManager().getDefaultdisplay().getRotation();
Matrix matrix = new Matrix();
RectF viewRect = new RectF(0,textureView.getWidth(),textureView.getHeight());
RectF bufferRect = new RectF(0,mPreviewSize.y,mPreviewSize.x);
float centerX = viewRect.centerX();
float centerY = viewRect.centerY();
if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
bufferRect.offset(centerX - bufferRect.centerX(),Matrix.ScaletoFit.FILL);
float scale = Math.max(
(float) textureView.getHeight() / mPreviewSize.y,(float) textureView.getWidth() / mPreviewSize.x);
matrix.postScale(scale,centerY);
}
matrix.postRotate(-90 * rotation,centerY);
textureView.setTransform(matrix);
}
项目:GitHub
文件:PageWidget.java
public PageWidget(Context context,String bookId,List<BookMixAToc.mixToc.Chapters> chaptersList,OnReadStatechangelistener listener) {
super(context,bookId,chaptersList,listener);
mPath0 = new Path();
mPath1 = new Path();
mMaxLength = (float) Math.hypot(mScreenWidth,mScreenHeight);
mPaint = new Paint();
mPaint.setStyle(Paint.Style.FILL);
createDrawable();
ColorMatrix cm = new ColorMatrix();//设置颜色数组
float array[] = {0.55f,80.0f,0.55f,0.2f,0};
cm.set(array);
mColorMatrixFilter = new ColorMatrixColorFilter(cm);
mMatrix = new Matrix();
mTouch.x = 0.01f; // 不让x,y为0,否则在点计算时会有问题
mTouch.y = 0.01f;
}
项目:GitHub
文件:ImageUtils.java
/**
* 快速模糊图片
* <p>先缩小原图,对小图进行模糊,再放大回原先尺寸</p>
*
* @param src 源图片
* @param scale 缩放比例(0...1)
* @param radius 模糊半径(0...25)
* @param recycle 是否回收
* @return 模糊后的图片
*/
public static Bitmap fastBlur(final Bitmap src,@FloatRange(from = 0,to = 1,fromInclusive = false) final float scale,to = 25,fromInclusive = false) final float radius,final boolean recycle) {
if (isEmptyBitmap(src)) return null;
int width = src.getWidth();
int height = src.getHeight();
Matrix matrix = new Matrix();
matrix.setScale(scale,scale);
Bitmap scaleBitmap = Bitmap.createBitmap(src,src.getWidth(),src.getHeight(),true);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
Canvas canvas = new Canvas();
PorterDuffColorFilter filter = new PorterDuffColorFilter(
Color.TRANSPARENT,PorterDuff.Mode.SRC_ATOP);
paint.setColorFilter(filter);
canvas.scale(scale,scale);
canvas.drawBitmap(scaleBitmap,paint);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
scaleBitmap = renderScriptBlur(scaleBitmap,radius,recycle);
} else {
scaleBitmap = stackBlur(scaleBitmap,(int) radius,recycle);
}
if (scale == 1) return scaleBitmap;
Bitmap ret = Bitmap.createScaledBitmap(scaleBitmap,true);
if (scaleBitmap != null && !scaleBitmap.isRecycled()) scaleBitmap.recycle();
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
项目:FaceRecognition
文件:ImageUtil.java
public static Bitmap convert(Bitmap a) {
int w = a.getWidth();
int h = a.getHeight();
Bitmap newb = Bitmap.createBitmap(w,h,Bitmap.Config.ARGB_8888);// 创建一个新的和SRC长度宽度一样的位图
Canvas cv = new Canvas(newb);
Matrix m = new Matrix();
//m.postScale(1,-1); //镜像垂直翻转
m.postScale(-1,1); //镜像水平翻转
//m.postRotate(-90); //旋转-90度
Bitmap new2 = Bitmap.createBitmap(a,w,m,true);
cv.drawBitmap(new2,new Rect(0,new2.getWidth(),new2.getHeight()),h),null);
return newb;
}
项目:GitHub
文件:WoWoPathView.java
private void initimage() {
if (headImageRes != 0) {
bitmap = BitmapFactory.decodeResource(getResources(),headImageRes);
if (headImageWidth != 0 || headImageHeight != 0) bitmap = getResizedBitmap(bitmap,headImageWidth,headImageHeight);
bitmapOffsetX = bitmap.getWidth() / 2;
bitmapOffsetY = bitmap.getHeight() / 2;
bitmapPosition = new float[2];
bitmapTan = new float[2];
matrix = new Matrix();
}
}
项目:GitHub
文件:BitmapHunterTest.java
@Test public void exifTransverse() {
Request data = new Request.Builder(URI_1).rotate(-45).build();
Bitmap source = Bitmap.createBitmap(10,10,ARGB_8888);
Bitmap result = transformResult(data,ORIENTATION_TRANsveRSE);
ShadowBitmap shadowBitmap = shadowOf(result);
assertthat(shadowBitmap.getCreatedFromBitmap()).isSameAs(source);
Matrix matrix = shadowBitmap.getCreatedFromMatrix();
ShadowMatrix shadowMatrix = shadowOf(matrix);
assertthat(shadowMatrix.getPostOperations()).containsExactly("scale -1.0 1.0");
assertthat(shadowMatrix.getPreOperations()).containsExactly("rotate 270.0");
}
项目:AnimationsDemo
文件:MatrixUtils.java
public static void mapPoints(Matrix matrix,float[] points)
{
float[] m = { 0.0F,0.0F,0.0F };
matrix.getValues(m);
points[0] = (points[0] * m[0] + m[2]);
points[1] = (points[1] * m[4] + m[5]);
if (points.length == 4) {
points[2] = (points[2] * m[0] + m[2]);
points[3] = (points[3] * m[4] + m[5]);
}
}
private void overlay(Bitmap bm1,Bitmap bm2) {
// Combine bitmaps
bmOverlay = Bitmap.createBitmap(bm1.getWidth(),bm1.getHeight(),bm1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
Paint paint = new Paint();
paint.setAlpha(128);
canvas.drawBitmap(bm1,new Matrix(),null);
canvas.drawBitmap(bm2,paint);
}
项目:JsoupSample
文件:TouchImageView.java
Fling(int veLocityX,int veLocityY) {
setState(State.FLING);
scroller = new CompatScroller(context);
matrix.getValues(m);
int startX = (int) m[Matrix.MTRANS_X];
int startY = (int) m[Matrix.MTRANS_Y];
int minX,maxX,minY,maxY;
if (getimageWidth() > viewWidth) {
minX = viewWidth - (int) getimageWidth();
maxX = 0;
} else {
minX = maxX = startX;
}
if (getimageHeight() > viewHeight) {
minY = viewHeight - (int) getimageHeight();
maxY = 0;
} else {
minY = maxY = startY;
}
scroller.fling(startX,startY,veLocityX,veLocityY,minX,maxY);
currX = startX;
currY = startY;
}
项目:HiddenCamera
文件:CameraPage.java
public static Bitmap rotateBitmap(Bitmap bitmap,int degress,boolean needRecycle) {
Matrix m = new Matrix();
m.postRotate((float)degress);
Bitmap bm = Bitmap.createBitmap(bitmap,true);
if(needRecycle) {
bitmap.recycle();
}
return bm;
}
项目:Expert-Android-Programming
文件:TouchImageView.java
/**
* Performs boundary checking and fixes the image matrix if it
* is out of bounds.
*/
private void fixTrans() {
matrix.getValues(m);
float transX = m[Matrix.MTRANS_X];
float transY = m[Matrix.MTRANS_Y];
float fixTransX = getFixTrans(transX,getimageWidth());
float fixTransY = getFixTrans(transY,viewHeight,getimageHeight());
if (fixTransX != 0 || fixTransY != 0) {
matrix.postTranslate(fixTransX,fixTransY);
}
}
项目:hypertrack-live-android
文件:ImageUtils.java
public static Bitmap getRotatedBitMap(File imageFile) {
if (imageFile == null || !imageFile.canRead() || !imageFile.exists()) {
return null;
}
Bitmap rotatedBitmap = null;
try {
Bitmap srcBitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath());
ExifInterface exif = new ExifInterface(imageFile.getName());
String orientString = exif.getAttribute(ExifInterface.TAG_ORIENTATION);
int orientation = orientString != null ? Integer.parseInt(orientString) : ExifInterface.ORIENTATION_norMAL;
int rotationAngle = 0;
if (orientation == ExifInterface.ORIENTATION_ROTATE_90) rotationAngle = 90;
if (orientation == ExifInterface.ORIENTATION_ROTATE_180) rotationAngle = 180;
if (orientation == ExifInterface.ORIENTATION_ROTATE_270) rotationAngle = 270;
Matrix matrix = new Matrix();
matrix.setRotate(rotationAngle,(float) srcBitmap.getWidth() / 2,(float) srcBitmap.getHeight() / 2);
rotatedBitmap = Bitmap.createBitmap(srcBitmap,srcBitmap.getWidth(),srcBitmap.getHeight(),true);
} catch (Exception e) {
e.printstacktrace();
CrashlyticsWrapper.log(e);
}
return rotatedBitmap;
}
项目:GitHub
文件:BarLineChartTouchListener.java
/**
* Constructor with initialization parameters.
*
* @param chart instance of the chart
* @param touchmatrix the touch-matrix of the chart
* @param dragTriggerdistance the minimum movement distance that will be interpreted as a "drag" gesture in dp (3dp equals
* to about 9 pixels on a 5.5" FHD screen)
*/
public BarLineChartTouchListener(BarLineChartBase<? extends BarLinescatterCandleBubbleData<? extends
IBarLinescatterCandleBubbleDataSet<? extends Entry>>> chart,Matrix touchmatrix,float dragTriggerdistance) {
super(chart);
this.mMatrix = touchmatrix;
this.mDragTriggerdist = Utils.convertDpToPixel(dragTriggerdistance);
this.mMinScalePointerdistance = Utils.convertDpToPixel(3.5f);
}
项目:RLibrary
文件:FingerPrinterView.java
/**
* 处理图片缩放
*/
private Bitmap setScale(Bitmap a) {
scale = ((float) (mWidth) / mBitWidth);
Matrix mMatrix = new Matrix();
mMatrix.postScale(scale,scale);
Bitmap bmp = Bitmap.createBitmap(a,a.getWidth(),a.getHeight(),mMatrix,true);
return bmp;
}
项目:XFrame
文件:XBitmapUtils.java
/**
* 获得带倒影的Bitmap
*
* @param bitmap 源Bitmap
* @return 带倒影的Bitmap
*/
public static Bitmap createReflectionBitmap(Bitmap bitmap) {
final int reflectionGap = 4;
int width = bitmap.getWidth();
int height = bitmap.getHeight();
Matrix matrix = new Matrix();
matrix.preScale(1,-1);
Bitmap reflectionImage = Bitmap.createBitmap(bitmap,height / 2,false);
Bitmap bitmapWithReflection = Bitmap.createBitmap(width,(height + height / 2),Config.ARGB_8888);
Canvas canvas = new Canvas(bitmapWithReflection);
canvas.drawBitmap(bitmap,null);
Paint deafalutPaint = new Paint();
canvas.drawRect(0,height + reflectionGap,deafalutPaint);
canvas.drawBitmap(reflectionImage,null);
Paint paint = new Paint();
LinearGradient shader = new LinearGradient(0,bitmapWithReflection.getHeight() + reflectionGap,0x70ffffff,0x00ffffff,TileMode.CLAMP);
paint.setShader(shader);
// Set the Transfer mode to be porter duff and destination in
paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
// Draw a rectangle using the paint with our linear gradient
canvas.drawRect(0,bitmapWithReflection.getHeight()
+ reflectionGap,paint);
return bitmapWithReflection;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。