bitmap

ImageView subclass to make Rounded Right Corner

放肆的年华 提交于 2020-01-16 16:47:28
问题 I am trying to take an image like these and turn them into the top right 1/4 of the image. The image below is an example of what I need. **UPDATE: ** I have it (sort of) working, but scaling the image creates an unacceptable amount of distortion my code seems terribly inefficient. Any ideas on how to improve this code or a possible better approach? I am subclassing Volley's NetworkImageView. Here is my code <com.RoundedNetworkImageView android:id="@+id/smallProductImage" android:layout_width=

ImageView subclass to make Rounded Right Corner

ぐ巨炮叔叔 提交于 2020-01-16 16:47:26
问题 I am trying to take an image like these and turn them into the top right 1/4 of the image. The image below is an example of what I need. **UPDATE: ** I have it (sort of) working, but scaling the image creates an unacceptable amount of distortion my code seems terribly inefficient. Any ideas on how to improve this code or a possible better approach? I am subclassing Volley's NetworkImageView. Here is my code <com.RoundedNetworkImageView android:id="@+id/smallProductImage" android:layout_width=

Android - Touch to erase portions of foreground ImageView to expose background View

你离开我真会死。 提交于 2020-01-16 11:27:26
问题 So I've been struggling with this for a better part of a day. Suppose I have a custom ImageView that I want to overlay over a background View (both within a RelativeLayout), which when touched, it erases portions of the View's source bitmap like an erase tool in MS Paint, exposing the View below it. I've checked pretty much all of the threads (like this one) and they suggest to use PorterDuff SRC Mode in the Paint object as well as creating a Canvas out out the ARGB_8888 shadow copy of the

How to convert a Icon to Bitmap in android? [duplicate]

拜拜、爱过 提交于 2020-01-16 08:22:42
问题 This question already has answers here : How to convert a Drawable to a Bitmap? (18 answers) Closed 3 years ago . I want to convert a Icon to Bitmap object in android. My goal is to convert from Notification Icon to bitmap. What should i do?? Thank you for all the answers! 回答1: Hope this helps Bitmap bitmapIcon = BitmapFactory.decodeResource(getResources(), R.drawable.icon); 回答2: You can use this class. Also I usually use this code. public static Bitmap drawableToBitmap (Drawable drawable) {

1 channel iplimage -> Android Bitmap

為{幸葍}努か 提交于 2020-01-16 01:00:31
问题 I need convert a 1-channel iplimage (gray) in an Android Bitmap. I have: IplImage aux = IplImage.create(senal_gray.width, senal_gray.height, IPL_DEPTH_8U, 4); cvCvtColor(senal_gray, aux, CV_GRAY2BGRA); Bitmap bm = Bitmap.createBitmap(aux.width, aux.height, Bitmap.Config.ARGB_8888); bm.copyPixelsFromBuffer(aux.getByteBuffer()); I think that the problem is in the order of channels, because with this code I get a translucent picture. Perhaps I need change the order of channels in "aux" to get

是否需要主动调用Bitmap的recycle方法

拈花ヽ惹草 提交于 2020-01-15 23:02:17
一个Bitmap使用完后,是只需要等它成为垃圾后让GC去回收,还是应该主动调用recycle方法呢?或者说,主动调用recycle方法是否有好处,是否能马上回收内存呢? 带着这个问题来看源码(我看的4.4源码)。 先看Bitmap内存的创建,通过跟踪Bitmap.createBitmap方法,可以发现是native方法里调用的JVM来创建的: jbyteArray arrayObj = env->NewByteArray(size); native使用的是通过其得到的一个固定地址: jbyte* addr = jniGetNonMovableArrayElements(&env->functions, arrayObj); native里会用一个SkPixelRef来存放他们: SkPixelRef* pr = new AndroidPixelRef(env, bitmapInfo, (void*) addr, bitmap->rowBytes(), arrayObj, ctable); 然后将这个传给Bitmap: bitmap->setPixelRef(pr); 再看recycle过程: java端: mBuffer = null; native端: Caches::getInstance().textureCache.removeDeferred(bitmap);

Create greyscale BMP from RGB BMP

℡╲_俬逩灬. 提交于 2020-01-15 16:42:51
问题 I have 24-bit image, I read bitmap and transform it to the grayscale and save like 8-bit. RGBTRIPLE temp; unsigned char t; ... t = (temp.rgbtBlue * 0.114 + temp.rgbtGreen * 0.587 + temp.rgbtRed * 0.299); fwrite(&t, sizeof(UCHAR), 1, newFile); After that image didn't open, I understand I must smth to change in headers. I try change size of file and size of bitmap in headers, but it didn't working. BITMAPFILEHEADER bfh; BITMAPINFOHEADER bih; ... bfh.bfSize = sizeof(UCHAR) * img.Width * img

Create greyscale BMP from RGB BMP

偶尔善良 提交于 2020-01-15 16:42:50
问题 I have 24-bit image, I read bitmap and transform it to the grayscale and save like 8-bit. RGBTRIPLE temp; unsigned char t; ... t = (temp.rgbtBlue * 0.114 + temp.rgbtGreen * 0.587 + temp.rgbtRed * 0.299); fwrite(&t, sizeof(UCHAR), 1, newFile); After that image didn't open, I understand I must smth to change in headers. I try change size of file and size of bitmap in headers, but it didn't working. BITMAPFILEHEADER bfh; BITMAPINFOHEADER bih; ... bfh.bfSize = sizeof(UCHAR) * img.Width * img

Create greyscale BMP from RGB BMP

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-15 16:42:29
问题 I have 24-bit image, I read bitmap and transform it to the grayscale and save like 8-bit. RGBTRIPLE temp; unsigned char t; ... t = (temp.rgbtBlue * 0.114 + temp.rgbtGreen * 0.587 + temp.rgbtRed * 0.299); fwrite(&t, sizeof(UCHAR), 1, newFile); After that image didn't open, I understand I must smth to change in headers. I try change size of file and size of bitmap in headers, but it didn't working. BITMAPFILEHEADER bfh; BITMAPINFOHEADER bih; ... bfh.bfSize = sizeof(UCHAR) * img.Width * img

IllegalArgumentException: x + width must be <= bitmap.width() in android

喜欢而已 提交于 2020-01-15 11:57:11
问题 I want to crop an image with in a margin (10,50,10,50),(left,top,right,bottom) respectively of an imageview. Here is my code Bitmap bitmap = Bitmap.createBitmap(imgView.getWidth(),imgView.getHeight(), Bitmap.Config.ARGB_8888); Bitmap result = Bitmap.createBitmap(bitmap, (imgView.getLeft() + 10), imgView.getTop() + 50,imgView.getRight() - 10,imgView.getBottom() - 50); bitmap.recycle(); Canvas canvas = new Canvas(result); imgView.draw(canvas); ie, if my imageview is of dimension 200X300.then i