bitmapdata

Fast Bitmap modifying using BitmapData and pointers in C#

岁酱吖の 提交于 2020-03-04 12:35:13
问题 I am capturing data from some camera (array of RAW data). Then I'm mapping this data to RGB values according to color palette. I need to map it as fast as possible, so I use BitmapDdata and edit pixels in unsafe piece of code using pointers. public void dataAcquired(int[] data) { Bitmap bmp = new Bitmap(width, height); BitmapData data = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); for (int i = 0; i < data.Length; i++) { int x = i % bmp

AS3 - Finding the highest y-coordinate for a given x-coordinate in BitmapData?

和自甴很熟 提交于 2020-01-06 02:59:07
问题 I'm making a platformer. Here is what I have so far: http://megaswf.com/s/2486396 (move around and jump with arrowkeys). I'm using the ground's bitmap data to test collisions with the player's coordinates, and the player is sinking into the ground a few pixels (especially when walking uphill). To prevent this, I want the player's y coordinate to instantly change so that the player is sitting on top of the ground. Here is what I'm working on: if (groundClipBmpData.hitTest(rLoc, 255, bLocFuture

AS3 PNG Encoder?

[亡魂溺海] 提交于 2020-01-05 03:03:37
问题 Is there a way to encode bitmap data into PNG for use with a FileReference.Save() method in AS3? I assume I need an encoder library. Where can I get a library that encode BitpmapData into PNG? 回答1: You're looking for: https://github.com/mikechambers/as3corelib There are probably other solutions, but this is widely used and well tested. I've used it myself on several occasions without issue. 回答2: Shameless plug! I just wrote a new PNG encoder called PNGEncoder2. It's extremely fast, offers

C# BitmapData class Scan0 and Stride properties meaning

谁都会走 提交于 2019-12-30 10:00:11
问题 Can anyone explain what Scan0 and Stride properties of BitmapData class in C# are for? 回答1: Are you talking about the BitmapData class? If so, the description in the documentation is reasonably clear, I think: Scan0: Gets or sets the address of the first pixel data in the bitmap. This can also be thought of as the first scan line in the bitmap. In other words, this lets you find the data to examine or change - or even lets you make the bitmap to a completely different piece of data. Stride:

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

PixelFormat.Format32bppArgb seems to have wrong byte order

烈酒焚心 提交于 2019-12-28 12:14:19
问题 I try to get all byte values from a Bitmap(System.Drawing.Bitmap). Therefore I lock the bytes and copy them: public static byte[] GetPixels(Bitmap bitmap){ if(bitmap-PixelFormat.Equals(PixelFormat.Format32.bppArgb)){ var argbData = new byte[bitmap.Width*bitmap.Height*4]; var bd = bitmap.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat); System.Runtime.InteropServices.Marshal.Copy(bd.Scan0, argbData, 0, bitmap.Width * bitmap.Height * 4);

Flex- Bitmapdata from multiple images (drag & dropped)

吃可爱长大的小学妹 提交于 2019-12-25 15:04:29
问题 Sorry, if the question title is little confusing (not very creative at it :) Here's the problem . I have an image loaded from BitmapData displayed in an Image control. This Image control has dragEnabled and user can drag and drop small images (from a bunch of images in a TileList) on top of it. The image loaded from the Bitmapdata can be different every time with different resolution and the Image control scales it down to fit its fixed with/height. But while saving the image after editing I

generating preview of BMP Image

泄露秘密 提交于 2019-12-24 22:15:41
问题 I am working on a Media up-loader which uploads images to Server. Before start upload file i want to show small thumbnail of Image. I used Loader class to load image selected by user & used Canvas to draw image on it. This works fine with images like jpg & png. But for bmp file loader class doesn't work. Is there anyway to load bmp image in Flex & Convert it to BitmapData ?? 回答1: I didn't test the example, but you could try this: Parsing and displaying BMP files via ActionScript And read the

How to bind data from BitmapData to WPF Image Control?

丶灬走出姿态 提交于 2019-12-24 10:45:35
问题 I'm using MVVM and in my ViewModel I've got some BitmapData collections. I want them to appear in my View as Images through data binding. How can I do that? Solution: [ValueConversion(typeof(BitmapData), typeof(ImageSource))] public class BitmapDataConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { BitmapData data = (BitmapData)value; WriteableBitmap bmp = new WriteableBitmap( data.Width, data.Height, 96, 96,

Save bitmap to file has zero in image size field

蓝咒 提交于 2019-12-24 09:35:51
问题 I find when I use the Bitmap.Save method with format ImageFormat.Bmp that the bitmap header info in the file has zero in the biSizeImage field. From what I can see this is ok according to the specs, but unfortunately the crappy embedded device I am forced to work with insists on it being set correctly. So the question is how to go about getting this header info field always set when the bitmap is saved? 回答1: The issue, as you suspect, is that 0 is a perfectly allowable value for the image