android-canvas

Android Crop Bitmap Canvas

淺唱寂寞╮ 提交于 2020-01-06 03:07:20
问题 I want to create the crop bitmap functionality and have referred Android: Free Croping of Image but this sets the bitmap in another imageView.Now I know I can set the cropped bitmap in the canvas but I want to retain the original bitmap and want to do the cropping in onDraw() and not make a different bitmap and then set it in canvas.I have tried to implement the below code in onDraw but there is no cropping and bitmap remains as it is.Pleas help so that I can code this in onDraw() method of

Delay in calling onDraw()

给你一囗甜甜゛ 提交于 2020-01-05 08:53:55
问题 I am writing a code which requires to update a UI multiple times within a second to display an animation .But after calling invalidate the onDraw() method gets called after around 100ms and hence the number of times the screen is repainted is reduced to only 4 or 5 times a second. I want to know as to what exactly causes the time difference between the invalidate() command and the calling of onDraw method. Is there any way I can reduce the delay so that my animation can be smooth?? Thanks in

Flickering while using surface view

笑着哭i 提交于 2020-01-04 19:00:54
问题 I am using surface view to show some graphics, the problem is that there is a flickering effect when I am moving the figure in the screen, I understand that this is due to double buffering problem, even though I went through many posts, I am unable to fix the problem, please take a look at my code and help me get this fixed. public class CustomSurfaceView extends SurfaceView implements Runnable{ Thread mThread = null; SurfaceHolder mSurfaceHolder; volatile boolean mRunning = false; Bitmap

ontouch in android: getting X and Y coordinates and drawing circle on that point

限于喜欢 提交于 2020-01-04 13:44:14
问题 in my application on ontouch of screen i'm getting the coordinates(x.y), after that on that position i'm drawing a circle.but when i'm drawing a circle on that position.it always draw a circle on upper left side corner of images on some pt.s .i'm not getting why this is happening.please help me. public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if(event.getAction()==MotionEvent.ACTION_UP) { Log.d("position", event.getX() + "-" + event.getY()); System.out

viewing canvas/bitmap on the fly while debugging in eclipse

早过忘川 提交于 2020-01-03 08:42:10
问题 Is there a way to debug canvas/bitmaps on Eclipse? I was wondering if I could view how the current canvas/bitmap looks when I set a breakpoint at a particular line. 回答1: Viewing bitmaps while debugging is possible now (though only with Android Studio). From the release notes for version 0.8.7 (Aug 21, 2014) Bitmap rendering in the debugger While debugging, you can now right click on variables in your app that are of type Bitmap, and invoke View Bitmap: This will then fetch the associated data

viewing canvas/bitmap on the fly while debugging in eclipse

空扰寡人 提交于 2020-01-03 08:41:30
问题 Is there a way to debug canvas/bitmaps on Eclipse? I was wondering if I could view how the current canvas/bitmap looks when I set a breakpoint at a particular line. 回答1: Viewing bitmaps while debugging is possible now (though only with Android Studio). From the release notes for version 0.8.7 (Aug 21, 2014) Bitmap rendering in the debugger While debugging, you can now right click on variables in your app that are of type Bitmap, and invoke View Bitmap: This will then fetch the associated data

How to draw a line to perfectly align top of a text?

谁说胖子不能爱 提交于 2020-01-03 06:21:31
问题 I am able to align the baseline perfectly. The getLineBounds will give a baseline that is perfectly aligned with text (lineBottom - descent). I am using rect.top as the topline which will give a line with padding on top see the screenshot. The main issue is I have different fonts.And this code works perfectly on some fonts. This is the code int baseline = getLineBounds(i, rect); int topLine = rect.top; canvas.drawLine(rect.left - padding, baseline, rect.right + padding, baseline, paint);

Draw multiple rectangles android canvas

别说谁变了你拦得住时间么 提交于 2020-01-03 05:33:27
问题 I'm trying to draw 4 rectangles on the canvas so that the canvas is divided in 4 equal rectangles. With the code I now have, only the last rectangle in my code is drawn. This is the code in my Activity: protected void onCreate(Bundle savedInstanceState) { ... setContentView(new MyView(this)); } public class MyView extends View { public MyView(Context context) { super(context); // TODO Auto-generated constructor stub setFocusableInTouchMode(true); } @Override protected void onDraw(Canvas

use canvas.drawBitmap in AsyncTask onPostExecute

喜你入骨 提交于 2020-01-03 03:36:25
问题 i use async task to draw bitmap on view,but it's draw nothing! this is the asynctask code class BitmapWorker extends AsyncTask<String, Void, Void> { private Canvas canvas; private Rect rcText; private Paint paint; private Options options; private Options opt; public BitmapWorker(Canvas canvas,Rect rcText,Paint paint) { this.canvas = canvas; this.rcText = rcText;//the bitmap must draw on it's rect this.paint = paint; } @Override protected Void doInBackground(String... params) { options = new

How to perform a similar operation as AffineTransform.transform on Android?

廉价感情. 提交于 2020-01-03 01:28:10
问题 public Point2D transform(Point2D ptSrc, Point2D ptDst) Transforms the specified ptSrc and stores the result in ptDst. If ptDst is null, a new Point2D object is allocated and then the result of the transformation is stored in this object. In either case, ptDst, which contains the transformed point, is returned for convenience. If ptSrc and ptDst are the same object, the input point is correctly overwritten with the transformed point. How do I perform a similar operation on Android? Any