android-bitmap

width and height must be > 0 error when using MPAndroidChart library

家住魔仙堡 提交于 2019-12-24 12:33:42
问题 I wanted to use MPAndroidChartLibrary in my application, but I am experiencing problems which I can't solve on my own. I would like to put the chart into the CardView which is stored inside ListView. CardView's xml looks like this: <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" > <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:android="http:/

Bitmap.getWidth()' on a null object reference

坚强是说给别人听的谎言 提交于 2019-12-24 09:07:49
问题 I just got into this problem on the line CreateScaledBitmap, I am trying to set this image as device's wallpaper and I need to scale this image to the device, thats why I am doing this method but unfortunately I cant fix this Bitmap width() error setWall.setOnClickListener(new View.OnClickListener() { @RequiresApi(api = Build.VERSION_CODES.KITKAT) @Override public void onClick(View view) { Picasso.with(getApplicationContext()).load(imageBrought).into(new Target() { @Override public void

How do I make the coordinates of MotionEvent match the ones of a scaled canvas?

◇◆丶佛笑我妖孽 提交于 2019-12-24 01:15:44
问题 I have a Canvas that is scaled so everything fits better: @Override public void draw(Canvas c){ super.draw(c); final float scaleFactorX = getWidth()/(WIDTH*1.f); final float scaleFactorY = getHeight()/(HEIGHT*1.f); if(c!=null) { final int savedState = c.save(); c.scale(scaleFactorX, scaleFactorY); (rendering) c.restoreToCount(savedState); } } It scales based on these two: public static final int WIDTH = 856; public static final int HEIGHT = 1050; Which causes the problem that the coordinates

Android - Draw text with solid background onto canvas to be used as a bitmap

那年仲夏 提交于 2019-12-23 02:34:17
问题 I've built an app that draws text with a boarder onto canvas that is then used as a bitmap and put into a google maps marker. What I would now like to do is remove the text boarder and create a solid black rectangle background behind the text instead. I've tried a couple of things but can't seem to get anything working on screen. Code so far: String text = "testText"; //create bitmap Bitmap.Config conf = Bitmap.Config.ARGB_8888; Bitmap bmp = Bitmap.createBitmap(300, 100, conf); //--style text

How to get the X and Y touch location inside the Bitmap

时光毁灭记忆、已成空白 提交于 2019-12-23 02:06:17
问题 I have an app in which it has a main canvas and i have added another canvas of bitmap on top of it. In the main canvas I have eraser in which it will detect when the user touches the bitmap area. I want to know the x and y inside the bitmap where the eraser touches and so on while moving from main canvas since the bitmap canvas is different from the main canvas. I want the x and y of the main canvas be the same with the bitmap canvas to be move. Thanks Here's my snippet public void touch_move

Bitmap scale destroy quality

坚强是说给别人听的谎言 提交于 2019-12-22 08:45:53
问题 I have made a Watch Face for Android Wear. But the problem is image scaling. Images for background, markers and gadgets are of reduced quality when I resize them. For example, I put 480x480 background image in drawable-nodpi folder (I have tried other dpi as well), and I rescale it like this: BitmapFactory.Options options = new BitmapFactory.Options(); options.inScaled = true; Bitmap bgImage = BitmapFactory.decodeResource(context.getResources(), R.drawable.ticks_1, options); bgImage = Bitmap

Can't save files on External Storage, even with user permissions [Android]

丶灬走出姿态 提交于 2019-12-22 08:17:46
问题 I'm developing an app for images manipulation on Android, but I'm stuck in writing the code for image saving. Here's the method I use: private void saveImageToExternalStorage(Bitmap finalBitmap) { String root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString(); File myDir = new File(root + "/saved_images"); myDir.mkdirs(); Random generator = new Random(); int n = 10000; n = generator.nextInt(n); String fname = "Image-" + n + ".jpg"; File file = new File

Can't catch Java (Android) Exception with try-catch , createBitmap

吃可爱长大的小学妹 提交于 2019-12-22 00:25:24
问题 I have a part of code, i use this code four times, but the the sixth time, my application crash , i don't get any Exception or error code. The code is: Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false); I try to use: try{ Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false); }catch (Exception e){ e.printStackTrace(); e.getMessage(); }catch (OutOfMemoryError o){ o.printStackTrace(); o.getMessage(); }catch (AssertionError a){ a

SVG to Bitmap at runtime conversion in Android [closed]

一笑奈何 提交于 2019-12-21 12:23:55
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . How can I convert SVG (Scaleable Vector Graphics) to Bitmap at runtime in Android? Kindly if possible provide me the exact chunk of code or exact links. I am quite new to Android application development. 回答1: Follow the svg-android tutorial to get a PictureDrawable from your SVG

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

久未见 提交于 2019-12-21 06:06:27
问题 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? 回答1: 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); } //