android-canvas

Recreate an object without deleting the last one

徘徊边缘 提交于 2019-12-11 14:10:13
问题 I'm creating an app that allows user to draw on the screen. My code actually creates a Path and next creates a line. But this when the user takes up his finger of the screen and goes to another part of the screen it make a line as it happen in the next video. http://youtu.be/CBv1wtUC2g4 The following code is the code of the drawview. public class DrawView extends View implements OnTouchListener { private static final String TAG = "DrawView"; List<Point> points = new ArrayList<Point>(); Paint

canvas.drawBitmap is not drawing anything

别等时光非礼了梦想. 提交于 2019-12-11 13:46:00
问题 I have overwritten onDragShadow for a DragShadowBuilder like so @Override public void onDrawShadow(Canvas canvas) { super.onDrawShadow(canvas); Bitmap bitmap = InGameActivity.getRandomBitmap(); Rect source = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); canvas.drawBitmap(bitmap, source, source, null); } I have verified that the bitmap is not null but when I drag, nothing is showing. Any ideas why? 回答1: If you want to draw the bitmap as is (i.e. you want the whole thing), use: canvas

How to retrieve an image from memory card in this scenario

流过昼夜 提交于 2019-12-11 12:54:26
问题 i am saving an image by passing a bitmap to the savephoto(Bitmap function) now i want to retrieve the photo which is saved ,, how to do that i am new in android , plz give me the code of retrival and also convert it into Bitmap public void savePhoto(Bitmap b2) { File imageFileFolder = new File(Environment.getExternalStorageDirectory(),"Rotate"); mageFileFolder.mkdir(); FileOutputStream out = null; Calendar c = Calendar.getInstance(); String date = fromInt(c.get(Calendar.MONTH)) + fromInt(c

What code should I use with 'drawMatrix.setPolyToPoly' to manipulate and draw just a rectangular part of a bitmap, rather than the entire bitmap?

*爱你&永不变心* 提交于 2019-12-11 12:23:20
问题 When i want to use just part of a bitmap without skewing or rotating it, like the top left fourth, the following works well: src_rect.set(0, 0, bmp_test.getWidth()/2,bmp_test.getHeight()/2); canvas.drawBitmap(src_rect, dst_rectF, paint); This draws just one fourth of the bitmap. However, if i want to rotate or skew just part of a bitmap using a matrix, the following does not work as expected: srcpairs[0] = 0; srcpairs[1] = 0; srcpairs[2] = (float)bmp_test.getWidth()/2; srcpairs[3] = 0;

Texture View video and Bitmap display

放肆的年华 提交于 2019-12-11 11:42:32
问题 I have a TextureView that displays a bitmap(placeholder image) and when the user loads a video the textureView should show the video. I managed to get video playback in the texture view and showing a bitmap in a textureview, but when done in sequence i just get a black screen. In my onSurfaceTextureAvailable method i draw a bitmap on the surface view as followed: @Override public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { Bitmap bm = BitmapFactory

Android android.graphics.Path width limited to 2036?

99封情书 提交于 2019-12-11 10:39:34
问题 I am trying to draw a very long line with a Path. The line is correctly displayed up until to a x target value of 2036. when i call path.lineTo(2037, y) the entire path is is not drawn. The call to canvas.drawPath(path, paint) does nothing. Is there a problem i am not aware of? On a second note... when i draw the same sequence of points via canvas.drawLines(float[], paint) the lines are correctly drawn but they are not antialiased. Is there a problem with antialiasing and drawLines? 回答1:

Scale a Canvas to fit a View programmatically

怎甘沉沦 提交于 2019-12-11 09:33:35
问题 I'm looking for help with the following scaling problem. I have built my own View class (custom view) which is a child of a Dialog . In this custom view I plot a graph in vertical direction from bottom to top. The graph can be greater or less than the size of the View . Therefore I would like to draw the graph onto the Canvas (which is greater than the View ) using the onDraw() method (see code below) and later scale the Canvas to fit into the View . Things I've tried already include using a

Draw arrow according to path

て烟熏妆下的殇ゞ 提交于 2019-12-11 09:29:28
问题 Currently I'm drawing a arrow head to my canvas by doing the following: mPaint.setStyle(Style.FILL); float deltaX = this.mPoints[1].x - this.mPoints[3].x; float deltaY = this.mPoints[1].y - this.mPoints[3].y; float frac = (float) 0.1; float point_x_1 = this.mPoints[3].x + (1 - frac) * deltaX + frac * deltaY; float point_y_1 = this.mPoints[3].y + (1 - frac) * deltaY - frac * deltaX; float point_x_2 = this.mPoints[1].x; float point_y_2 = this.mPoints[1].y; float point_x_3 = this.mPoints[3].x +

Canvas.drawRect() stops drawing after updating to Android Studio 0.6.0

旧时模样 提交于 2019-12-11 08:50:29
问题 I recently updated my Android app (see source on Github) to use Android Studio 0.6.0, which required bumping the build-tools to v19.1.0 (from v19.0.1), the Android Gradle plugin to v0.11 (from 0.9), and the Gradle wrapper to 1.12 (from 1.11). Before the above changes (at this commit), the app was successfully drawing squares on a canvas to show signal strength of GLONASS satellites (see IDs 87 and 88): After updating my Android tools and launching via Android Studio or gradlew installDebug ,

OutofMemoryError when creatingBitmp

ぃ、小莉子 提交于 2019-12-11 08:18:47
问题 When Creating bitmap for canvas in onSizeChanged() I am getting OutOfMemoryError I am creating Bitmap like this Bitmap b = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); I am getting OutOfMemoryError exception when zooming canvas. How I can handle this exception? 来源: https://stackoverflow.com/questions/24303759/outofmemoryerror-when-creatingbitmp