bitmap

how can I save a bitmap with onRetainNonConfigurationInstance() for screen orientation?

北战南征 提交于 2020-01-21 04:49:07
问题 In my class view phone cam will be opened and programme shows the bitmap after user take photo from phone cam but at the same time the user rotates the screen to "landscape" bitmap will disappear and activity's oncreate() will load again and then camera will be opened again. I didnt know save bitmap with onRetainNonConfigurationInstance() or onSaveInstanceState(). The question is this how can I save the bitmap(taken from phone cam) before user rotates the phone so that even if phone is

getDrawingCache() returns null

别来无恙 提交于 2020-01-21 04:45:49
问题 I'm working on a simple painting app and trying to implement the functionality of giving more space to draw when a user requests, which I thought could be done by simply enabling scrolling of my CustomView class(which is contained in a LinearLayout then in a ScrollView class). If I didn't resize the CustomView class by running Chunk 1, Chunk 2 works fine(It simply saves one screen of drawing. At this time, there is no scrolling.) A bummer! Chunk 2 fails(view.getDrawingCache() returns null)

Customizing clickable area on a Marker in Google Maps v2 for Android

喜你入骨 提交于 2020-01-20 05:53:10
问题 I am currently using Google Maps v2 API for Android and doing some custom overlays. For starters, I create a custom bitmap that is quite a big larger than the standard "marker". I know that using an older Maps API, you can create a custom overlayitem which controls the click-able area, but it must also be possible on the newer Maps API. I simply want my custom marker's click-able area to be the same as the custom bitmap icon I am setting it to. I have read over the examples and documentation

Image Uri to File

旧街凉风 提交于 2020-01-20 05:21:52
问题 I've got an Image Uri, retrieved using the following: public Uri getImageUri(Context inContext, Bitmap inImage) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes); String path = Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null); return Uri.parse(path); } This works just amazing for Intents that require an Image URI, etc (so I know for sure the URI is valid). But now I want to save this Image URI

Take a picture with camera and get bitmap [duplicate]

淺唱寂寞╮ 提交于 2020-01-20 03:59:07
问题 This question already has answers here : Capture Image from Camera and Display in Activity (14 answers) Closed 5 years ago . I am working on an app for android that uses the front facing camera to simulate a mirror for the user. I need the app to take a picture every 5 seconds as a bitmap(automatically and without user interaction), which I then combine with another bitmap later on. The difficult part for me: How to take a picture and get it as a bitmap? I tried several solutions, but none

How can I copy the pixel data from a Bitmap with negative stride?

大憨熊 提交于 2020-01-19 14:16:20
问题 I was looking for the fastest way to convert a Bitmap to 8bpp. I found 2 ways: 1. public static System.Drawing.Image ConvertTo8bpp(Bitmap oldbmp) { using (var ms = new MemoryStream()) { oldbmp.Save(ms, ImageFormat.Gif); ms.Position = 0; return System.Drawing.Image.FromStream(ms); } } 2. http://www.wischik.com/lu/programmer/1bpp.html But: 1. Results in a very low quality result (bad pallet) and 2 gives me a Bitmap with negative stride, when I try to lockbits and copy the data to a byte array I

超实用Image类

蓝咒 提交于 2020-01-19 11:48:26
using System; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Runtime.InteropServices; public static class ImageHelper { private static float[][] ColorMatrix = null; static ImageHelper() { float[][] numArray = new float[5][]; numArray[0] = new float[] { 0.299f, 0.299f, 0.299f, 0f, 0f }; numArray[1] = new float[] { 0.587f, 0.587f, 0.587f, 0f, 0f }; numArray[2] = new float[] { 0.114f, 0.114f, 0.114f, 0f, 0f }; float[] numArray2 = new float[5]; numArray2[3] = 1f; numArray[3] = numArray2; numArray2 = new float[5]; numArray2[4] = 1f; numArray[4] = numArray2;

Android 绘图时实现双缓冲

我与影子孤独终老i 提交于 2020-01-19 07:51:00
一、双缓冲技术原理:   在内存中创建一片内存区域,把将要绘制的图片预先绘制到内存中,在绘制显示的时候直接获取缓冲区的图片进行绘制。更具体一点来说: 先通过setBitmap方法将要绘制的所有的图形绘制到一个Bitmap上也就是先在内存空间完成,然后再来调用drawBitmap方法绘制出这个Bitmap,显示在屏幕上。 二、双缓冲技术出现的缘由   当一个动画争先显示时,程序又在改变它,前面的画面还没显示完,程序又要求重新绘制,这样屏幕就会不停闪烁。为了避免闪烁,使绘制的内容有一个平滑的过度,所以就出现了双缓冲技术——》将要处理的图片都放在内存中处理好后,再将其一次性显示到屏幕上。这样出来的就是完整的图像,不会出现闪烁现象。 二、双缓冲技术的优缺点   优点:     1.绘制过程中一般不会出现闪烁现象,能使动画平滑过度。     2.高效,将图像一次性绘制到屏幕上比一次一次的绘制要高效的多。   缺点:     当图片过大时会严重的消耗内存 三、实现双缓冲的步骤   1.创建一片内存区域用于存放目标Bitmap        // 创建一个200*200的缓冲区 bitmapBuffer = Bitmap.createBitmap(200, 200, Config.ARGB_8888);   2.设置目标内容绘制到缓冲区     // 设置将目标内容绘制在“缓冲区” canvas

java 多个二维码读取报错

依然范特西╮ 提交于 2020-01-19 00:45:54
多个二维码的图片读取返回数组,在异常里处理 public static String decode(File file) throws Exception { BufferedImage image; image = ImageIO.read(file); if (image == null) { return null; } BufferedImageLuminanceSource source = new BufferedImageLuminanceSource(image); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); Result result=null; Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(); hints.put(DecodeHintType.CHARACTER_SET, CHARSET); //优化精度 hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); //复杂模式,开启PURE_BARCODE模式 hints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE

WRONG onActivityResult() being called

浪子不回头ぞ 提交于 2020-01-17 12:46:05
问题 I have 2 activities A, B and both are using onActivityResult() in them. The process: onActivityResult() in A works fines. I have two onActivityResult() (shown in code below) in Activity B .First one as a clickable TextView which is also working fine. The other as Button . The problem I'm facing is in the Button which is suppose to bring a Bitmap from sub-activity of B and display in a ImageView in B. . When I click the Button it takes me to the onActivityResult() of the Activity A.