android-bitmap

How to properly save frames from mp4 as png files using ExtractMpegFrames.java?

十年热恋 提交于 2019-12-07 04:01:23
I am trying to get all frames from an mp4 file using the ExtractMpegFrames.java class found here http://bigflake.com/mediacodec/ExtractMpegFramesTest.java.txt What I currently do is create a temp file (File.createTempFile) in a directory that stores all the frames, create a FileOutputStream and do bm.compress(Bitmap.CompressFormat.PNG, 100, fOut) where fOut is the OutputStream with the file. Currently, the saved images look like this: https://imgur.com/a/XpsV2 Using the Camera2 Api, I record a video and save it as an mp4. According to VLC, the color space for the video is Planar 4:2:0 YUV Full

Android: Rotate and display image from file

爱⌒轻易说出口 提交于 2019-12-07 00:26:29
问题 I have a very simple layout with an ImageView. My application opens the camera, saves an image, and then displays the image in the ImageView with BitmapFactory.decodeFile . The only issue is that it's rotated. I understand that a) this is due to the phone's camera defaulting to landscape, so this needs to be handled in code and b) image processing must be done in a separate thread from the UI. The Android training documentation seems to be geared toward loading images from resource id's

Creating a bitmap of a drawn square in android opengl es 2.0

旧时模样 提交于 2019-12-06 15:04:19
问题 I have drawn a square using opengl es 2.0 and now i want to create a bitmap of that drawn square. Can anyone please guide me on how to do that? Please let me know if my question is not clear. Thanks 回答1: It is done using glReadPixels(). This is slow, but is the only method available with OpenGL ES 2.0 on Android. In Java: Bitmap buttonBitmap = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.ARGB_8888); ByteBuffer byteBuffer = ByteBuffer.allocateDirect(mWidth * mHeight * 4); GLES20

How to upscale an image without it becoming blurry

倾然丶 夕夏残阳落幕 提交于 2019-12-06 12:20:11
I have an ImageView that is 32x32. Its a sprite basically. But when I go to upscale the image, it blurs like this: But I want it to scale up in the application like this: This is the code I have tried, but it doesn't work. I want the final image to be put on an ImageView. @Override public View getView(int i, View view, ViewGroup viewGroup) { View v = view; ImageView picture; TextView name; if(v == null) { v = inflater.inflate(R.layout.gridview_item, viewGroup, false); v.setTag(R.id.picture, v.findViewById(R.id.picture)); v.setTag(R.id.text, v.findViewById(R.id.text)); } picture = (ImageView)v

Android universal music player add album cover in the MediaItemViewHolder

家住魔仙堡 提交于 2019-12-06 11:00:39
问题 Not sure how many people here are familiar with the Android Universal Music Player but I am having issue with displaying an album in the MediaItemViewHolder.java file. So here is a basic structure after my modifications: // image view for the album cover holder.mImageView = (ImageView) convertView.findViewById(R.id.play_eq); // get the album art url String artUrl = description.getIconUri().toString(); Bitmap art; AlbumArtCache cache = AlbumArtCache.getInstance(); art = cache.getIconImage

Can't apply a colorFilter to text selection handles

[亡魂溺海] 提交于 2019-12-06 08:09:13
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">@drawable/text_cursor_mtrl_alpha</item> It works as expected. However, in Lollipop these drawables are tinted

Android: Convert image object to bitmap does not work

99封情书 提交于 2019-12-06 01:34:00
I am trying to convert image object to bitmap, but it return null. image = reader.acquireLatestImage(); ByteBuffer buffer = image.getPlanes()[0].getBuffer(); byte[] bytes = new byte[buffer.capacity()]; Bitmap myBitmap = BitmapFactory.decodeByteArray(bytes,0,bytes.length,null); The image itself is jpeg image, I can save it to the disk fine, the reason I want to convert to bitmap is because I want to do final rotation before saving it to the disk. Digging in the Class BitmapFactory I see this line. bm = nativeDecodeByteArray(data, offset, length, opts); This line return null. Further Digging

How to make Picasso/Glide work with Html.ImageGetter for caching images?

懵懂的女人 提交于 2019-12-06 00:30:35
Thanks for all the effort @Budius has made. Most part of image work of my app could be handled by Picasso/Glide, however, some images are displayed in a TextView by Html.fromHtml . And the images in TextView are also used frequently. However, I don't know how to implement getDrawable() method with Picasso/Glide for the ImageGetter passed to Html.fromHtml . Is it possible to share the same cache of Picasso/Glide for these pictures in TextView and other bitmaps? Or should I use an custom LruCache instead to cache these pictures form ImageGetter separately? Will this way increase the risk of an

Bitmap scale destroy quality

∥☆過路亽.° 提交于 2019-12-05 14:47:19
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.createScaledBitmap(bgImage , width, height, false); Here are the images: and this is what I get on the

Android: Rotate and display image from file

余生长醉 提交于 2019-12-05 04:31:41
I have a very simple layout with an ImageView. My application opens the camera, saves an image, and then displays the image in the ImageView with BitmapFactory.decodeFile . The only issue is that it's rotated. I understand that a) this is due to the phone's camera defaulting to landscape, so this needs to be handled in code and b) image processing must be done in a separate thread from the UI. The Android training documentation seems to be geared toward loading images from resource id's instead of file paths. This just throws a wrench in things as I'm able to follow the tutorials up to a point