android-bitmap

Android WEBP encoding in API v18 and above: bitmap.compress(Bitmap.CompressFormat.WEBP, 100, outputStream) doesn't save the alpha channel for API < 22

江枫思渺然 提交于 2019-12-11 06:47:36
问题 The app is compiled with following version config: compileSdkVersion 23 buildToolsVersion "23.0.2" minSdkVersion 18 targetSdkVersion 23 The app has a bitmap which contains transparent regions. I'm using WEBP format to save the bitmap to file. Bitmap config is ARGB_8888 bitmap.hasAlpha() returns true Tested the particular pixels in the Bitmap before saving and verified that some regions are transparent. bitmap.compress(Bitmap.CompressFormat.WEBP, 100, fileOutputStream) The above code works

scaled bitmap according to device resolution

£可爱£侵袭症+ 提交于 2019-12-11 06:27:14
问题 I am getting strange issue of White blank screen when i try to set image inside my image view after scaling it from bitmap. I am getting random size images from server , I just need to show them in my image view without loose in quality of image. i have taken one layout and add image view dynamically through code. Here is what i am doing in code :- Getting Url form server and scaling it accordingly :- url="http://www.petstory.co/attached_king_photos/hotel/7/attached

Drawing multiple lines on canvas with delay in between

a 夏天 提交于 2019-12-11 05:10:40
问题 after few months i finally managed to create my first non trivial app. Now I want to add some nice animation (not sure it is a proper term), like step-by-step drawing my graph. Gif below explains what I need. At this point my app draw the graph at once, without any delaying. In MyFragment class there is FrameLayout where custom View (my graph) is added: public class MyFragment extends Fragment{ ... FrameLayout mFL; MyDraw mydraw = new MyDraw(getContext(),floatArray_coord_X,floatArray_coord_Y)

How to scale (zoom and move) to x,y coordinates of Bitmap in PhotoVIew?

安稳与你 提交于 2019-12-11 03:06:11
问题 I use the lib https://github.com/chrisbanes/PhotoView At start I have Bitmap and x,y point on the Bitmap. How to scale and zoom image to x,y coordinates of the bitmap? int bitmapWidth = bitmap.getWidth();//2418 int bitmapHeight = bitmap.getHeight();//1889 float x = 1209f; float y = 944f; float targetScale = 4f; attacher.setScale(targetScale, x,y, false);//it doesnt work scale = 1f scale = 4f and I want programly move center to x,y coordinates 回答1: I was facing the same issue, and finally made

How to draw a bitmap to a SurfaceView?

孤者浪人 提交于 2019-12-10 18:08:30
问题 I am trying to draw a bitmap to my SurfaceView actually with the following code: (this will be run in another Thread and in a while , because it needs to refresh the SurfaceView ). while (true) { try { // Enable drawing // ERROR LINE! Canvas ca = mPreview2.Holder.LockCanvas(); // Get current frame Bitmap test = mediaPlayer.CurrentFrame; // Actual drawing Paint paint = new Paint(); ca.DrawBitmap(test, 0, 0, paint); // Stop drawing mPreview2.Holder.UnlockCanvasAndPost(ca); } catch (Exception ex

Compressing an image to meet a file size limit (Android)

做~自己de王妃 提交于 2019-12-10 16:29:10
问题 I've implemented the below code to scale an image down, with respect to the aspect ratio (by proportionally decreasing height/width with respect to one another).. This will definitely help to reduce the size of the images uploaded to my backend, but this does not take into account the resolution of the images. I want to set a hard image limit, say 800Kb, and if the image is greater than 800Kb after resizing, then compress to a point at which it is less than 800Kb. Anyone have any experience

Can't apply a colorFilter to text selection handles

守給你的承諾、 提交于 2019-12-10 11:08:42
问题 I'm trying to bring material text selection handles to my app. I got drawables from the SDK for middle/right/left handle (bitmaps) and text cursor (9-patch), and set: <item name="android:textSelectHandleLeft">@drawable/text_select_handle_left_mtrl_alpha</item> <item name="android:textSelectHandleRight">@drawable/text_select_handle_right_mtrl_alpha</item> <item name="android:textSelectHandle">@drawable/text_select_handle_middle_mtrl_alpha</item> <item name="android:textCursorDrawable">

Trying to scale down a Bitmap in Android not working

99封情书 提交于 2019-12-10 03:49:20
问题 I'm trying to scale down a bitmap. In short, the image is originally from a ByteArray with a width of 4016. After I scale the image down with factory options, it still reports the image with a width of 4016. Here are two clips of my code: Bitmap myBitmap = null; @Override protected byte[] doInBackground(Object... params) { final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; if (options.outHeight > options.outWidth) { options.inSampleSize =

Get Bitmap from TextureView efficiently

喜欢而已 提交于 2019-12-09 15:37:51
问题 I am trying to get each frame from a TextureView , unfortunately trying: textureView.getBitmap(); Results in slow performance is there a faster way to obtain a bitmap. Is it better to use the NDK instead? Looking for actual examples 回答1: A TextureView receives frames on a SurfaceTexture, which takes frames sent to its Surface and converts them to a GLES texture. To get the pixel data out, the texture must be rendered to a framebuffer, then read out with glReadPixels() . The pixel data can

Using canvas and bitmap in Android , how to get this image?

微笑、不失礼 提交于 2019-12-09 10:38:02
问题 I am new in android. I am trying to draw this image(match statistic) and fill the image with color with 10% to 100% . I tried this much and this is image this is the code public class DrawView extends View { Paint paint = new Paint(); public DrawView(Context context) { super(context); } @Override public void onDraw(Canvas canvas) { paint.setColor(Color.BLACK); paint.setStrokeWidth(3); canvas.drawRect(30, 30, 100, 100, paint); paint.setStrokeWidth(0); paint.setColor(Color.GRAY); canvas