android-canvas

Multiple RelativeSizeSpan on same line

拈花ヽ惹草 提交于 2019-12-07 13:06:50
问题 I'm trying to use two RelativeSizeSpan next to each other, but a big gap appears in between. See what I want to achieve and what I'm getting. This is how I'm building the Spanned instance String formattedValue = "25%"; SpannableStringBuilder ssb = new SpannableStringBuilder(formattedValue); ssb.append("\n"); ssb.append(otherValue); int firstSpanEnd = formattedValue.length(); ssb.setSpan(new RelativeSizeSpan(1.5f), 0, firstSpanEnd-1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); ssb.setSpan(new

How to resize bitmap when drawing in canvas?

半腔热情 提交于 2019-12-07 12:25:43
问题 In my android app, I have this function that creates a new bitmap from an old one via canvas. private static Bitmap convert(Bitmap bitmap, Bitmap.Config config, int width, int height) { Bitmap convertedBitmap = Bitmap.createBitmap(width, height, config); Canvas canvas = new Canvas(convertedBitmap); Paint paint = new Paint(); paint.setColor(Color.BLACK); canvas.drawBitmap(bitmap, 0, 0, paint); bitmap.recycle(); return convertedBitmap; } The problem is when I draw the old bitmap onto the canvas

emojis not rotating with canvas

喜你入骨 提交于 2019-12-07 12:20:09
问题 I have created an applications that allows users to paint with text, including emojis. The user can rotate and resize the text to their liking. The problem occurs when the user rotates text that includes emojis. As you can see, there is unwanted overlap. I have deduced that this is because i draw the text twice to achieve a border affect. Whats interesting, is that the problem solves itself if the text size exceeds a certain amount. this can be seen in the bottom most test. Here is the code

How to Move a ShapeDrawable in Canvas on Touch Events

血红的双手。 提交于 2019-12-07 11:58:59
问题 I am trying to implement a Drawing Application in Android. Where the user should be able to select and move the drawn shapes. Currently i have statically drawn some rects and text on my Drawing Canvas: View mDrawingCanvas = new View(mContext) { ShapeDrawable rectangle; @Override public boolean isFocused() { // TODO Auto-generated method stub Log.d(TAG, "View's On focused is called !"); return super.isFocused(); } @Override public boolean onTouchEvent(MotionEvent event) { // TODO Auto

Skewed images in ImageView on Android 4.1.2

亡梦爱人 提交于 2019-12-07 10:29:23
问题 I have an app that displays an image in an ImageView , and am experiencing problem specifically for Android 4.1.2. It is confirmed to not work on three separate 4.1.2 devices, while working on 2.3.7, 4.2.1, 4.3 and 4.4.2. The error occurs for several different images, but not all. There seems to be something about some specific JPEG-files that doesn't work as intended. How it actually looks, and how it shows on Android 4.1.2: The above image (left) is one such problematic image file. A

getDrawingCache is not updated

核能气质少年 提交于 2019-12-07 10:05:31
问题 I'm calling getDrawingCache in the onDraw function. The problem is that it contains the changes to the canvas only in the first time, and after that, it's not updated at all with the new changes. Here's my code: paintAction.draw(canvas); if (paintAction.isPermanentChange()) { Bitmap partialBitmap=getDrawingCache(); int numColored=0; for (int index1=0;index1<partialBitmap.getWidth();index1++) { for (int index2=0;index2<partialBitmap.getHeight();index2++) { if (partialBitmap.getPixel(index1

Android. Canvas scale and translate

风格不统一 提交于 2019-12-07 09:56:54
问题 I created custom view where you can touch and scale it. Most of work was created with the help of this post Next i observe that if i want to zoom in image it is always zooming to top left corner. Here is my onDraw() method: @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.save(); canvas.translate(mPosX, mPosY); canvas.scale(mScaleFactor, mScaleFactor); // actual drawing canvas.getClipBounds(mRect); canvas.restore(); } So this is normal behaviour for canvas.scale

Android Canvas OpenGL Renderer is out of memory

Deadly 提交于 2019-12-07 08:50:43
问题 I develop android library for drawing chart at view, using canvas. However, the following errors occur frequently. LogCat: D/NvOsDebugPrintf(11526): NvRmChannelSubmit: NvError_IoctlFailed with error code 12 D/NvOsDebugPrintf(11526): NvRmChannelSubmit failed (err = 196623, SyncPointValue = 94008102) (87 times repeat) D/OpenGLRenderer(11526): GL error from OpenGLRenderer: 0x505 E/OpenGLRenderer(11526): OpenGLRenderer is out of memory! Solution is not found although I am groping for various

android use a View from a XML layout to draw a canvas

喜你入骨 提交于 2019-12-07 05:04:13
问题 So basically i want to use a xml layout, but i also want a canvas where i can have graphics performed. What i did was make a view in my xml layout as you can see below. Then in my application i made the view draw the canvas, but it is not working. I'm not sure if my method for solving this is completely wrong or what. So please just take a look at my code and tell me if you see a quick fix or if you have a better method. Thanks in advance I really appreciate it. <?xml version="1.0" encoding=

Load bitmap into canvas and draw over it

依然范特西╮ 提交于 2019-12-07 04:02:27
I like to make an app, something like a little paint, I have to get a bitmap, draw it on a canvas and next, draw over it (with figer)... So, I actually have this code: import java.io.File; import java.io.FileOutputStream; import java.util.ArrayList; import android.content.Context; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.os.Environment; import android.util.Log; import android.graphics.Bitmap; import android.view.MotionEvent; import android.view.View; import