android-canvas

How to get when an ImageView is completely loaded in Android

天涯浪子 提交于 2019-12-04 00:25:35
问题 I'm developing an App which draws lines over a bunch of Images. To choose these images, I have a radio group and, whenever the user clicks in a radio button, the image is load with all its own drawings. In my radio listenner I have the following code: bitmap = BitmapUtils.decodeSampledBitmapFromResource(root + DefinesAndroid.CAMINHO_SHOPPINGS_SDCARD + nomeImagemAtual, size.x, size.y); mImage.setImageBitmap(bitmap); mImage.setDrawLines(true); mImage.setImageBitmap(loadBitmapFromView(mImage));

Getting Bitmap from WebView generates OutOfMemory crash

爱⌒轻易说出口 提交于 2019-12-04 00:18:51
I have a custom WebView and I want to get a bitmap of its content (offscreen included). I used this code, which I got from here : public static Bitmap getBitmapFromWebviewV2(WebView webView) { webView.measure(View.MeasureSpec.makeMeasureSpec( View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); webView.layout(0, 0, webView.getMeasuredWidth(), webView.getMeasuredHeight()); webView.setDrawingCacheEnabled(true); webView.buildDrawingCache(); Bitmap bm = Bitmap.createBitmap(webView.getMeasuredWidth(), webView

Android - Drawing to a PDF canvas from WebView

核能气质少年 提交于 2019-12-03 23:23:54
I've been having troubles getting PDF printing work on Android. What I'm trying to do is render some HTML in WebView, then draw the WebView contents on a PDF canvas and finally write the PDF to a file. The problem I'm having is that when I draw to the PDF canvas the content gets clipped even though there is plenty of canvas left. I've tried resizing the canvas using the .clipRect(Rect rect, Op op) and that kind of worked but not as well as I would've liked. I also have no idea how I can translate the HTML px measurements to the PDF PostScript 1/72th inch measurements reliably. Here's the code

How to save objects previously drawn to the Canvas on a redraw?

大城市里の小女人 提交于 2019-12-03 21:29:54
Every time a SurfaceView is redrawn, things that were previously drawn are erased. How do I save their state so that my loop will add new objects to the screen without erasing the old ones? Draw with a Bitmap : Bitmap mDrawBitmap; Canvas mBitmapCanvas; Paint mDrawPaint = new Paint(); @Override public void onDraw(Canvas canvas) { if (mDrawBitmap == null) { mDrawBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888); mBitmapCanvas = new Canvas(mDrawBitmap); } // draw on the btimapCanvas //... and more mBitmapCanvas.drawWhatever(...); // after drawing with the bitmapcanvas

Android - is there a possibility to make infinite canvas?

淺唱寂寞╮ 提交于 2019-12-03 21:13:50
问题 Currently I am doing app allowing user to draw. Simple think, just extend Canvas class and most of the thing is done. That was my initial thinking and idea. But as the canvas is rather small because this is only what user see on the screen there is not much possible space to draw. Going through documentation I found translate() method allowing me to move canvas. What I did find out is when I move it, there is some kind of blank space just as you would move piece of paper. I understand that

What does lockCanvas mean (elaborate)

ぃ、小莉子 提交于 2019-12-03 19:15:19
问题 I'v been coming to drawing graphics in Android. There's a lot of sample applications out there, but one thing I always seeing is lockCanvas. Can someone explain it closer since I really don't get it and also because im think it's important to understand to future programming? An example: try { c = panel_thread.getHolder().lockCanvas(null); synchronized (panel_thread.getHolder()) { panel_thread.update(); panel_thread.onDraw(c); } } This is what I have for now. How should I interpret this

Magnifying part of the canvas when touched

微笑、不失礼 提交于 2019-12-03 19:07:06
问题 I have a custom view that extends SurfaceView. I am drawing an image on the canvas. When the user touches a point on the canvas, i want to show a magnified view of the area around the touched co-ordinates. And preferably, as the finger moves around, i would like to update the magnified view's content accordingly. I was wondering if the android platform supports such a functionality natively. If not, can one of you point me to a good example that can get me started or share ideas on how to

Android graph view

房东的猫 提交于 2019-12-03 17:32:14
I have used jjoe64's graphview library to implement graph in my app. It has pretty good samples inside the box and started right away to include it in my app. Wat i have got so far is as shown below. But what i actually need is as shown below, I dont want that dark vertical lines to come inside the graph. Any idea how to remove these vertical lines. Also i wanted to add the markers at each graph points. The markers are usually png's. And the last, i wanted the change the vertical label sizes. Can somebody help me out with this. Thanks. You can use achartengine for more effective customization.

Android: How to save custom finger paint view on orientation change

淺唱寂寞╮ 提交于 2019-12-03 17:12:12
I'm trying to create a custom view where a user can draw their signature. One where you can put it into the view programmatically and set the size, etc. I haven't had to do this before so I based it off the fingerpaint class from android api demos. Problem right now is that it erases the object on orientation change and I'm not sure how to get it to not do that. The code for PaintView private Bitmap mBitmap; private Canvas mCanvas; private Path mPath; private Paint mBitmapPaint; private boolean mDrawPoint; private int stateToSave; private Paint mPaint; public PaintView(Context context) { super

How to use canvas of view extended class into activity class?

ε祈祈猫儿з 提交于 2019-12-03 17:11:30
I created one class: public class TestCanvas extends View { public TestCanvas(Context context) { super(context); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); paint.setColor(Color.RED); canvas.drawText("kal", 0, 100, paint); canvas.save(); } } Now I call that class from activity: public class TestActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TestCanvas tcanvas=new TestCanvas(); frameLayout=(FrameLayout)findViewById(R.id.frameLayout1)