bitmap

BitmapFactory null issue in android

微笑、不失礼 提交于 2019-12-25 08:51:05
问题 I am trying to create bitmap class using bitmapfactory. I get camera preview image in YUV format and decode manually to grayscale image. When i try to create bitmap object via BitmapFactory it returns null. try { for (int y = 0; y < frameHeight; y++){ for (int x = 0; x < frameWidth; x++){ byte grey = YUVData[y * frameWidth + x]; convertedData[y * stride + 3 * x] = grey; convertedData[y * stride + 3 * x + 1] = grey; convertedData[y * stride + 3 * x + 2] = grey; } } Bitmap bitmap =(Bitmap)

Memory heavy oval gradient

那年仲夏 提交于 2019-12-25 08:49:26
问题 As you may know it is not possible to draw an oval radial gradient using regular Android API. This is what I want to achieve: So I implemented this solution: draw a regular radial gradient on a square bitmap and then this bitmap will get stretched by the view itself (idea found here: https://stackoverflow.com/a/3543899/649910) This works great however this solution takes a lot of memory, because of BitmapDrawable usage (see implementation details below). Any ideas on how to avoid usage of

Android undo drawing method on canvas

你说的曾经没有我的故事 提交于 2019-12-25 08:15:13
问题 I created some code that takes a picture and displays the picture, then the user is able to draw on the picture. I want to implement an undo method. I based my code on many examples I've read. The problem is in my onDraw method - the examples don't use drawBitmap but for me I have to draw the bitmap on the canvas in order for the image to show up. The code shown displays the image, allows drawing on the image, but does not undo the drawings. I can't figure out what's wrong/how to fix it.

Image load in imageView from gallery become black

笑着哭i 提交于 2019-12-25 08:14:21
问题 So I load image from galley and display into ImageView , the image turn to black. But not all images, just a certain. Why would this happen? @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case RESULT_LOAD_IMAGE: if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK & null != data) { imageUri = data.getData(); imageView.setImageURI(imageUri); } break; } } Then I

android - animation by drawing bitmap is not smooth

我们两清 提交于 2019-12-25 07:48:18
问题 I am trying to animate several shapes(paths) by drawing them on the surface holders canvas. At first I was drawing them as paths and everything was fine, the movement was smooth. As I increased the number of objects(shapes) the performance decreased and I made some tests to see if instead of drawing shapes drawing bitmaps is faster. And.. drawing bitmaps seems to be considerable faster (less computation maybe) BUT the movement is not smooth. It looks like the bitmaps always move from pixel to

android decode string base 64 to bitmap

 ̄綄美尐妖づ 提交于 2019-12-25 07:39:28
问题 Hi guys I wanted to ask you one thing, I have a chat that transfers strings and I can even attach of JPEG images before sending them to convert it into a string and then decode in BITMAP just that when I decode it crashes the app. I wanted to know if it is the right code to decode it. NOME = (TextView) row.findViewById(R.id.comment); NOME.setText(coment.comment); String a = NOME.getText().toString(); if(a.length() > 1024 ) { byte[] image = Base64.decode(a, 0); int lung = a.length(); Bitmap

Bitmap from URL Android

我怕爱的太早我们不能终老 提交于 2019-12-25 07:27:06
问题 I'm trying to get a png Bitmap from URL but the Bitmap is always NULL in with this code: private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> { ImageView bmImage; Activity activity; public DownloadImageTask(ImageView bmImage, Activity activity) { this.bmImage = bmImage; this.activity = activity; } protected Bitmap doInBackground(String... urls) { String urldisplay = urls[0]; Log.i("LEGGERE", urldisplay); Bitmap mIcon11 = null; try { URL url = new URL(urldisplay); mIcon11 =

Bitmap Image not displaying from a URL link Blackberry

浪尽此生 提交于 2019-12-25 07:22:32
问题 For some reason my blackberry application crashes whenever i try to display a bitmap image from a URL using the internet. I found the downloadImage() function very easy to understand and to follow compared to others on stackoverflow. The others didnt have any examples on how to implement their function. I have have tested the function downloadImage many times and all failed. Please give explanation with code example. Thanks. Anyway, The compiler stops at this point here: g.drawBitmap(10, y +

Setting bitmap to imageview from filepath is not working

给你一囗甜甜゛ 提交于 2019-12-25 07:11:41
问题 I tried almost all methods possible to set image to a image-view from stored file path. None of them work. The images were selected from gallery in other activity and imagepath stored into database. Images are of type .jpg .jpeg .png Image paths stored in database with paths without any extensions eg. /external/storage/media/carimagename when I try to set image to imageview using this code there is no error but image is not set. for(int i=0;i<n;i++) { Bitmap pic = BitmapFactory.decodeFile

ImageView not changing image when source is changed (already using invalidate)

南笙酒味 提交于 2019-12-25 07:10:35
问题 I have an imageView with a set image in xml. However when I try to change the image the ImageView never displays the second image. Instead it displays a blank screen. I have tried the code with and without invalidate() and there is no change. ImageView image; String imgPath=Environment.getExternalStorageDirectory()+"/Music/Evanescence - Discography - 1998-2011 (320 kbps)/Album's/2000 Origin (Limited Edition) (320 kbps)/Scans covers/06.jpg"; @Override protected void onCreate(Bundle