android-canvas

Rotating Image on A canvas in android

会有一股神秘感。 提交于 2019-11-26 07:26:32
问题 I want to Rotate Image according to a specific angle in android ,some thing like a compass... I have this code...it works on drawPath() but i want to replace the path and the Drawing thing with image.. I tried to create a bitmap image ,DrawBitmapImage , but the image does not Rotate like the path..Any Help PLease? public void draw(Canvas canvas) { double angle = calculateAngle(currentLongitude, currentLatitude, targetLongitude, targetLatitude); //Correction; angle-=90; //Correction for

Work around Canvas.clipPath() that is not supported in android any more

纵饮孤独 提交于 2019-11-26 06:39:34
问题 From android 3.0 the clipPath() method is no longer supported in devices with hardware acceleration turned on.(Read this article for more details). I am working with canvas and I need to draw rounded image. Any ideas about how can I do that? *I can\'t turn the hardware acceleration off, I am looking for other solution. Answered: Tnx @Malcolm for your answer. I found a good example that demonstrate this technique, it\'s basically a mask. 回答1: Canvas.clipPath() support with hardware

How to draw a filled triangle in android canvas?

守給你的承諾、 提交于 2019-11-26 05:27:31
问题 So I\'m drawing this triangle in android maps using the code below in my draw method: paint.setARGB(255, 153, 29, 29); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setAntiAlias(true); Path path = new Path(); path.moveTo(point1_returned.x, point1_returned.y); path.lineTo(point2_returned.x, point2_returned.y); path.moveTo(point2_returned.x, point2_returned.y); path.lineTo(point3_returned.x, point3_returned.y); path.moveTo(point3_returned.x, point3_returned.y); path.lineTo(point1_returned

Android, canvas: How do I clear (delete contents of) a canvas (= bitmaps), living in a surfaceView?

自作多情 提交于 2019-11-26 03:37:18
问题 In order to make a simple game, I used a template that draws a canvas with bitmaps like this: private void doDraw(Canvas canvas) { for (int i=0;i<8;i++) for (int j=0;j<9;j++) for (int k=0;k<7;k++) { canvas.drawBitmap(mBits[allBits[i][j][k]], i*50 -k*7, j*50 -k*7, null); } } (The canvas is defined in \"run()\" / the SurfaceView lives in a GameThread.) My first question is how do I clear (or redraw) the whole canvas for a new layout? Second, how can I update just a part of the screen? // This

Image on canvas to JPEG file

有些话、适合烂在心里 提交于 2019-11-26 02:33:48
问题 I\'m drawing 2D images on the canvas. I want to save image shown on canvas to JPEG file, how can I do it? 回答1: create an empty bitmap create a new Canvas object and pass this bitmap to it call view.draw(Canvas) passing it the canvas object you just created. Refer Documentation of method for details. Use Bitmap.compress() to write the contents of the bitmap to an OutputStream, file maybe. Pseudo code: Bitmap bitmap = Bitmap.createBitmap( view.getWidth(), view.getHeight(), Bitmap.Config.ARGB

Out of Memory error with Bitmap

[亡魂溺海] 提交于 2019-11-26 02:24:49
问题 During runtime, I am trying to put an image in the surface view. When I tried using the image from the Drawable folder I got Out of memory error. After a quick search in the stackoverflow, I found that there will be some relief if we access the image from the asset folder. But still I get the Out of memory error during runtime. I have analyzed and found that scaling will help in resolving this kind of memory related issues. The thing is that I have the image size of 1280 x 720 and the device

converting a canvas into bitmap image in android

一笑奈何 提交于 2019-11-26 01:59:30
问题 I am trying to develop an app on canvas,I am drawing a bitmap on the canvas.After drawing,i am trying to convert into bitmap image. can anyone give me a suggestion. thank you in advance. 回答1: Advice depends upon what you are trying to do. If you are concerned that your controls take a long time to draw, and you want to draw to a bitmap so you can blit the bitmap rather than re-drawing via a canvas, then you don't want to be double-guessing the platform - controls automatically cache their

Image in Canvas with touch events

早过忘川 提交于 2019-11-26 01:47:11
问题 Seems simple, and yet I\'m having problems with implementation. I want a canvas with image on screen including onTouch events. I have tried ImageView but I was not able to use canvas. I have tried SurfaceView and was able to show image in canvas on screen but I have problems with motion onTouch events (zoom, pan). I need canvas because I will render the image in my code. Can someone please show me the right way of doing this? 回答1: You can use this: import android.content.Context; import

Image in Canvas with touch events

瘦欲@ 提交于 2019-11-25 21:37:27
Seems simple, and yet I'm having problems with implementation. I want a canvas with image on screen including onTouch events. I have tried ImageView but I was not able to use canvas. I have tried SurfaceView and was able to show image in canvas on screen but I have problems with motion onTouch events (zoom, pan). I need canvas because I will render the image in my code. Can someone please show me the right way of doing this? You can use this: import android.content.Context; import android.graphics.Canvas; import android.graphics.drawable.BitmapDrawable; import android.util.AttributeSet; import