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
2
votes
2 answers

How can I color pixels that are not black in bitmap in yellow using LockBits?

Using GetPixel and SetPixel is easy but very slow so I'm trying to using LockBits. I have this method I did long time ago to compare between two images: public static Bitmap FastComparison(Bitmap bmp1,Bitmap bmp2) { tolerancenumeric =…
James Aharon
  • 223
  • 1
  • 4
  • 13
2
votes
1 answer

Why does Bitmap.LockBits fail on VM's

I use an XP VM and a Vista VM for smoke testing my applications before I deploy them. Both of these VM's are using 32bit color. Not sure if it makes any difference but I'm using VirtualBox. Each machine is also allocated 2GB of ram, 2 processors. XP…
Richard Moss
  • 1,550
  • 3
  • 26
  • 43
1
vote
2 answers

Lockbits with ushort greyscale values

I want to create a bitmap from given 16 bit greyscale values. So far I have this code: var value = CamData.ToArray(); var b = new Bitmap(160, 112, PixelFormat.Format24bppRgb); var bdata = b.LockBits(new Rectangle(0, 0, 160, 112),…
h0ppel
  • 347
  • 2
  • 5
  • 21
1
vote
2 answers

C#, Lockbits image processing with artefacts, changing pixel format

Im implementing my own function to binarize fingerprint images. In my method i try to work with LockBits for the first time. Could you explain me, why i get a lot of artefacts on my images? Eample: On the left picture i binarize image by…
user9687180
1
vote
0 answers

GDI+ Bitmap LockBits returns rotated image?

I loaded an image from file and want to write it to AVI file: Gdiplus::Bitmap frame(L"test.png", FALSE); Gdiplus::BitmapData bmp_data = {}; Gdiplus::Rect rect(0, 0, frame.GetWidth(), frame.GetHeight()); frame.LockBits(&rect,…
Andriy Tylychko
  • 15,967
  • 6
  • 64
  • 112
1
vote
0 answers

Vb.Net 2015 - Issue with byte array storage and comparisons using lockbits/marshal.copy

I'm new here, so pardon me if my question is not in the proper format to produce a response. Please let me know if I need to add anything: I'm currently working on a project from home for a mate at a company that uses a really old legacy system that…
RiGMiK
  • 11
  • 2
1
vote
0 answers

Lockbits: The array sequence is mutating somewhere

I'm using the lockbit method to manipulate an image, but I have noticed that after I save the image using the save method of the Bitmap type, the data that I manipulate in the byte array I get out of the lockbit, is manipulated. For example…
Arnold Zahrneinder
  • 4,788
  • 10
  • 40
  • 76
1
vote
0 answers

Purpose of ImageLockMode in Bitmap.LockBits

I'm working in C# and I've got a question about the Bitmap.LockBits method. Let's say that I have a Bitmap called myBitmap and use LockBits on this bitmap: BitmapData bmpData = myBitmap.LockBits(new Rectangle(0, 0, myBitmap.Width, myBitmap.Height),…
Henrik123
  • 53
  • 5
1
vote
2 answers

C# LockBitmap - xy-coordinate to Pixel byte conversion

I am trying to learn LockBitmap class for image processing and I came across this code posted below. Basically it returns the color of a x-y coordinate. Of course this method only works after I perform source.LockBits() and Marshal.Copy() / unsafe…
Liren Yeo
  • 3,215
  • 2
  • 20
  • 41
1
vote
1 answer

How to use DrawEllipse in a LockBits array (How to generate a set of pixels that forms an ellipse)

I'm using this class to fill pixels of a bitmap based on the LockBits function: Imports System.Drawing.Imaging Imports System.Runtime.InteropServices.Marshal Public Class Fill Public Shared Function Process(ByVal b As Bitmap) As Bitmap …
1
vote
1 answer

How do I correct this LockBits math error?

Using GetPixel/SetPixel, I was using the following to power an image filter that emphasizes reds and purples: for (int y = 0; y < bmpMain.Height; y++) for (int x = 0; x < bmpMain.Width; x++) { bmpMain.GetPixel(x, y); Color c…
MaoTseTongue
  • 71
  • 2
  • 8
1
vote
1 answer

Mifare Ultralight C Lock

I'm attempting to lock a Mifare Ultralight C tag. I want to set NDEF pages 0x04 to 0x27 to read-only. I think this can be achieved via Ndef.makeReadonly(). Additionally, I would like to set pages 0x29 to 0x2F to be password protected (for read and…
Rob
  • 43
  • 3
1
vote
1 answer

LockBits() Throwing 'Out Of Memory' in Parallel Foreach?

Iam new to the c# and Parallel processing. I am trying to process the bunch of images and i have written methods for processing.And I have added the Parallel foreach loop on imagelist as below Parallel.ForEach(Directory.GetFiles(path), new…
user2721874
1
vote
0 answers

Getting Each Colour of Pixel From my LockBits

I have a program which gets every pixel in an image and outputs them into a text document. The problem is that it just throws them in there are as numbers and it looks rather ugly. e.i. " 37 37 37 36" I wish to display them much like the GetPixel…
rguarascia.ts
  • 694
  • 7
  • 19
1
vote
1 answer

Enlarging an image without blurring by taking one pixel and turning it into four on a new image with different dimensions

I have previously written an image enlarger algorithm that enlarges images without blurring by doubling the image size and making a single pixel into four pixels on the new image. This was originally built for 500x500 pixel images and it worked…
Henry Hunt
  • 181
  • 5
  • 12