bitmap

Error android.graphics.Canvas.throwIfRecycled when overlaying bitmaps

梦想与她 提交于 2020-01-24 03:05:14
问题 Im trying to overlay images on a canvas using the following method: private Bitmap overlay(Bitmap bmp1, Bitmap bmp2) { bmOverlay = Bitmap.createBitmap(70, 70, Bitmap.Config.RGB_565); canvas = new Canvas(bmOverlay); canvas.drawBitmap(bmp1, 0, 0, null); //line 179 canvas.drawBitmap(bmp2, 0, 0, null); return bmOverlay; } However, my app keeps crashing and the log reads: java.lang.NullPointerException at android.graphics.Canvas.throwIfRecycled(Canvas.java:954) at android.graphics.Canvas

Loading bitmap manually

自闭症网瘾萝莉.ら 提交于 2020-01-24 02:04:27
问题 I'm trying to write some C# code, which will take an name to a .bmp located on the disk. To that I have been following the wikipedia page : BMP File Format So i have created 2 classes to contain the headers. Firstly the file header : class BMPFileHeader { public BMPFileHeader(Byte[] headerBytes) { // Position int offset = 0; // Read 2 byes bfType = ((char)headerBytes[0]).ToString(); bfType += ((char)headerBytes[1]).ToString(); offset = offset + 2; // Read 4 bytes to uint32 bfSize =

How to convert coordinates on Bitmap to real coordiates on Image View displayed on screen

大兔子大兔子 提交于 2020-01-24 01:08:31
问题 I have an Image View which displays an image (e.g 2000x1000 pixels) and I have a coordinate (X,Y) on that image (not the image view). The canvas of my Image View is 600x800 for example. How can I convert the point (X,Y) to screen coordinate so that I can draw a path with them on the OnDraw(...) method of Image View. Any help is appreciated! Thank you. Update: If I use matrix to draw the path between coordinates, it works but the path and objects i draw become really small. Here is the code i

Out of memory during working with Bitmap in android

醉酒当歌 提交于 2020-01-23 21:36:26
问题 I use the method quoted below to round the corners of any bitmap. Some time it works perfectly, some time not because of OutOfMemory exception. The exception often occur at the line Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Do I miss any special codes here? Please help me. public static Bitmap roundBitmap(Bitmap bitmap, int roundedRadius) { if (bitmap == null) return null; if (roundedRadius == 0) { return bitmap; } // Bitmap output = bitmap

Loading a large number of images from a spritesheet

我与影子孤独终老i 提交于 2020-01-23 17:17:46
问题 I'm attempting to make a simple game of Pairs for Android. Program Structure: Menu.java (Menu activity initially loaded) Game.java (Game activity, started by Menu) GameThread.java (Handles gameloop, calls render process in GameView) GameView.java (Handles all drawing to the screen) Graphics.java (Stores loaded images) The Problem: The game features 15 different types of card, each of which requires around 14 frames for animation (flipping, destroying, etc). I'm currently reading these off a

System::Drawing::Bitmap to unsigned char *

拈花ヽ惹草 提交于 2020-01-23 17:09:27
问题 I have a C# .NET library that grabs frames from a camera. I need to send those frames to a native application that takes images from an unsigned char* . I initially take the frames as System::Drawing::Bitmap . So far I can retrieve a byte[] from the Bitmap . My test is done with an image of resolution 400*234, I should be getting 400*234*3 bytes to get to the 24bpp a RGB image requires. However, I'm getting a byte[] of size 11948. This is how I convert from Bitmap to byte[] : private static

Get images from DrawingGroup

别来无恙 提交于 2020-01-23 01:40:06
问题 Maybe it's a stupid question, but I have some problems with finding the proper answer:S How to get frames as Bitmap 's or Image 's (or something similar) from DrawingGroup ? I don't actually know how to bite it. I tried to look for it in the Internet, but had problems with finding something useful. 回答1: If you need an image to be used as the Source of an Image control, you could simply put the drawing into a DrawingImage: var drawing = ... var drawingImage = new DrawingImage(drawing); image

Access violation when assigning a value to my component Bitmap property [closed]

南笙酒味 提交于 2020-01-22 03:12:06
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I'm trying to create a component that must use a Bitmap, I'm having a problem when I go to select the image on the property. Here is an excerpt of the code: Property Declaration Property StarOff: TBitmap read

SVG with embedded bitmap not showing bitmap when using <img> tag in webkit browser

狂风中的少年 提交于 2020-01-21 08:30:06
问题 I am trying to use a SVG with an embedded bitmap as a navigation element. The idea is to make it more mobile friendly. I already have a PNG fallback in place for IE8 and below. Somehow the embedded bitmap doesn't show in webkit based browsers. SVG without bitmap embedded show just fine. I can get the background to show in webkit using the "object" tag but then my links don't work, I can't control the width and I run into a documented bug of safari where image is not scaled and sliders appear.

Generate image file with low bit depths?

冷暖自知 提交于 2020-01-21 06:27:10
问题 bpp = bits per pixel, so 32bpp means 8/8/8/8 for R/G/B/A. Like .NET has an enum for these "System.Drawing.Imaging.PixelFormat". Now once I have a Bitmap or Image object with my graphics, how would I save it to a file / what format would I use? What image file format (JPEG/GIF/PNG) supports low bit-depths like 16bpp or 8bpp (instead of the usual 32bpp or 24bpp) 回答1: Try this: ImageCodecInfo pngCodec = ImageCodecInfo.GetImageEncoders().Where(codec => codec.FormatID.Equals(ImageFormat.Png.Guid))