Questions tagged [lockbits]

Part of .NET's System.Drawing Namespace - Bitmap.LockBits Method

Locks a Bitmap into system memory

Docs: https://learn.microsoft.com/en-us/dotnet/api/system.drawing.bitmap.lockbits?view=netframework-4.7

95 questions
1
vote
3 answers

C# - Remove Bitmap padding

I was wondering if there's a way in order to remove the padding generated by the 24 bit Bitmap for each scan line. What I mean is like this : Original [Pure Cyan 24 Bit BMP] : FF FF 00 FF FF 00 FF FF **00 00** FF FF 00 FF FF 00 FF FF 00 Desired…
CudoX
  • 985
  • 2
  • 19
  • 31
1
vote
2 answers

Edge Detection with Lockbits C#

I made a program that implements an edge detection algorithm, but it takes a long time to process. I've read about using lockbits, and unsafe state instead of getpixel and setpixel, but I still don't understand how to use it. This is my example…
christ2702
  • 473
  • 6
  • 12
  • 26
1
vote
1 answer

C# - Creating BMP from Bytes

I'm creating a WinForm Application in C# that I can use to "sniff out" some 24 bit bitmaps in a file. I already gathered information such as its offset, some analysis on how it is written in the file, and its length. So more information about the…
CudoX
  • 985
  • 2
  • 19
  • 31
1
vote
1 answer

C# Lockbits for more exotic PixelFormats

I'm writing a performance critical class in C# for image manipulation. I'm using LockBits to gain access to the actual data directly and all is working well but I'd like to get more info on the memory signature of certain PixelFormats, most notably…
David Rutten
  • 4,716
  • 6
  • 43
  • 72
1
vote
1 answer

Lockbits doesn't affect my Image

I'm building a 3d (red,cyan) program. It went well, but when combining, the "image" (see in code) doesn't seemed to be affected. What is my mistake? Assume: RImage_P(point) = {5,5} startCyan(point) = {0,0} startRed(point) = {5,5} CImage, RImage…
D.christian
  • 167
  • 1
  • 9
1
vote
1 answer

Image Recognition between 2 images vb.net Lockbits

I was in the process of using Pixel to do my search between a large image and a small image. I got that one to successfully work but am having trouble getting the lockbits version to do what I want it to do. Fist I want to loop through the large…
1
vote
1 answer

Where are the RGB values stored in this array?

I've been using the following sub in my control that I'm creating to let me modify the pixels in a bitmap faster: Protected Sub LockForMemory() idata = ime.LockBits(New Rectangle(0, 0, ime.Width, ime.Height), ImageLockMode.WriteOnly,…
Freesnöw
  • 30,619
  • 30
  • 89
  • 138
1
vote
2 answers

Why does BitmapData.Stride ignore the size of the rectangle passed to LockBits?

I have an image and want to read the pixel values in a particular region. I assumed that the rectangle which is the 1st argument of the LockBits() method was there to allow for sub-sections to be specified. When debugging though, I noticed that the…
Tom Wright
  • 11,278
  • 15
  • 74
  • 148
0
votes
1 answer

Locking Bits Fails To Detect Pixels

I am creating a program that scans all the pixels of an image, and whenever it finds a pixel that contains the color pink. It makes the pixel black. But it doesn't seem to find a pink pixel when there is two of them on the image. I do not know if I…
Daniel Lopez
  • 1,728
  • 3
  • 24
  • 40
0
votes
0 answers

ActionViolation when using LockBits

I am trying to get the pixels a bit faster than one could when using .GetPixel() but I have found myself that it throws an exception with a 0,0 index with the right LockImageMode. Exception Attempted to read or write protected memory. This is often…
PontiacGTX
  • 185
  • 2
  • 15
0
votes
1 answer

Creating a Color object for each pixel while using Bitmap.LockBits faster than BitMap.GetPixel?

Is creating a Color object for each pixel while using Bitmap.LockBits still faster than using Bitmap.GetPixel for each pixel? Or maybe creating that Color is the main overhead of Bitmap.GetPixel as compared to the LockBits method?
axk
  • 5,316
  • 12
  • 58
  • 96
0
votes
0 answers

I Have a bug in my simple Lockbits Image class

I have this simple class to plot points on an image. It is limited to 24bbp. but at certain widths the image breaks, colors are distorted and the image moves towards the right the lower down in the image it gets. its only correct when the width is a…
0
votes
1 answer

How to make a NFC Tag read only?

I have an NTAG213 NFC sticker. I was wondering how I can make this sticker read only. If later I switch to a NTAG215, how could I make that tag read only. What is the process involved in actually making different types of stickers read only. When I…
James
  • 299
  • 1
  • 12
0
votes
0 answers

Issue with Lockbits in DrawImage

Looking for some much appreciated help. I'm trying to draw a smaller bitmap into a larger bitmap. I'm trying to use Lockbits to make the process go faster. But my .DrawImage function will not execute. The error is a general GDI+ error (Unhandled…
le2020
  • 1
  • 1
0
votes
0 answers

color values different per monitor with getpixel/lockbits

Im trying to make a method that returns the color value of a specific pixel. The problem i am having it that the same piece of code returns a different ARGB on different monitors. Currently im using this method: public static Color…
Neoray
  • 71
  • 1
  • 6