bitmap

Drawing a Long String on to a Bitmap results in Drawing Issues

大兔子大兔子 提交于 2019-12-29 08:46:07
问题 I'm working with drawing a long string to a bitmap (talking more than a million characters), including multiline characters \r\n , written by a StringBuilder . My Text to Bitmap code is as follows: public static Bitmap GetBitmap(string input, Font inputFont, Color bmpForeground, Color bmpBackground) { Image bmpText = new Bitmap(1, 1); try { // Create a graphics object from the image. Graphics g = Graphics.FromImage(bmpText); // Measure the size of the text when applied to image. SizeF

Moving image with touch events

北城以北 提交于 2019-12-29 08:21:28
问题 I need a sample code for when we move(touch) a image from left to right and right to left. Please help me. Regards, chakri 回答1: try this code... this is your main activity class import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.widget.ImageView; import android.widget.LinearLayout.LayoutParams; import android.widget

Objective C - save UIImage as a BMP file

喜欢而已 提交于 2019-12-29 08:17:07
问题 Similar questions have been asked but they always contain the answer "use UIImagePNGRepresentation or UIImageJPEGRepresentation" which will not work for me. I need to save the file as a bitmap. From my understanding, the UIImage data is already a bitmap. In which case I shouldn't have to create a bitmap. Or do I? I found someone who posted this question but I'm unsure what exactly the answer is, as it is not clear to me. I've even gone so far as to create a char pointer array but I still don

Saving Bitmap as 32bpp doesn't keep transparency

余生颓废 提交于 2019-12-29 08:17:05
问题 using (var bmp = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppArgb)) using (var g = Graphics.FromImage(bmp)) { g.Clear(Color.Transparent); g.DrawImage(image, 0, 0); bmp.Save("image.bmp", ImageFormat.Bmp); } The question should be clear: why saving to BMP trashes transparency to black , while saving to PNG keeps it ? Just to clarify: image is in Format8bppIndexed format and its palette does contain transparent colors (e.g. it draws correctly onto form/picturebox) Edit: My bad,

Gray out the Desktop screen except a selected control in c#

南楼画角 提交于 2019-12-29 08:08:08
问题 I want to select a UI control to be clicked and gray out the rest of the desktop screen semi-transparently. I was thinking bitmap painting the whole screen but it is very slow process. I guess someone out there know in WPF how to do that. I don't have experiance in WPF. I wanted to do this on Windows 7. 回答1: Basically you want to show a top-level full screen transparent window which is not focusable and doesn't respond to input. You can then use this window to draw the overlay manually. I

Is it possible to use .png images for WiX bitmaps

ⅰ亾dé卋堺 提交于 2019-12-29 07:34:09
问题 I am using 2 500K bitmaps in to display images on my WiX dialogs. They dramatically increase the size of the installation package, and what is worse - it looks there's no way to package them as a part of a .cab file since they're <binary> -es in the WiX terms. So, I thught, is there any way to use other file formats for bitmaps or WiX is tethered with BMP? Ideally it would be greate if there's a way to use .png format since it comes with a looseless compression option. 回答1: The Windows

How do you load a bitmap file into a BitmapData object?

谁说我不能喝 提交于 2019-12-29 05:08:49
问题 In Flash, the BitmapData object can be used to store bitmaps in RAM, you can later draw them to a MovieClip using the beginBitmapFill() method. How do you load an external bitmap file (.jpg) into a BitmapData object? Even AS3 code would be helpful. 回答1: AS3 code to load a PNG and "get" its bitmapData var bitmapData:BitmapData; var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete); loader.load(new URLRequest("../lib/img.png")); function

Skewing a bitmap only in the vertical direction

左心房为你撑大大i 提交于 2019-12-29 04:54:47
问题 I want to skew (correct me if this is not the correct word) a bitmap so that it appears to have depth. A good way to visualize what I am asking for is how the credits of Star Wars are angled to show depth. I have tried the following: canvas.getMatrix().postSkew(kx,ky,px,py); and canvas.skew(sx,sy); But I have not had much success. The above methods seem to always transform the bitmap into a parallelogram. Is there a way to transform the bitmap into a trapezoid instead? Here is a snippet of

Set individual pixels in .NET Format16bppGrayScale image

妖精的绣舞 提交于 2019-12-29 04:47:27
问题 I'm trying to render a small Bitmap in memory with .NET that needs to be 16 bit Grayscale. The bitmap's format is set to PixelFormat.Format16bppGrayScale. However, Bitmap.SetPixel takes a Color argument. Color in turn takes one byte for each of R, B, and G (and optionally A). How do I specify a 16-bit gray scale value rather than an 8 bit value when drawing to my bitmap? 回答1: Regardless of the image format, SetPixel() is brutally slow. I never use it in practice. You can set pixels much

Catching OutOfMemoryError in decoding Bitmap

妖精的绣舞 提交于 2019-12-29 03:20:27
问题 Is it a good practice to catch OutOfMemoryError even you have tried some ways to reduce memory usage? Or should we just not catching the exception? Which one is better practice? try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 4; bitmap = BitmapFactory.decodeFile(file, options); } catch (OutOfMemoryError e) { e.printStackTrace(); } Thanks 回答1: It's good practice to catch it once and give decodeFile another chance. Catch it and call System.gc() and try