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
3
votes
1 answer

Are Bitmap.LockBits and Graphics.FromImage combinable in C#

Can you combine the methods of Bitmap.LockBits and Graphics.FromImage, or in other words if I have a bitmap "bmp" and I want to edit the bitmap with a Graphics-object g, are the changes visible in the byte-array of the BitmapData.Scan0: Bitmap bmp =…
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
3
votes
2 answers

Set white and black pixel depends on brightness

I'm trying to find the needle from these or similar pictures: My solution is take average brightness of picture and set black and white pixels depends on it. The result is something like this: I dont need to see numbers and staf there.. only…
Palike
  • 67
  • 1
  • 9
3
votes
1 answer

Writing to Image using Lock Bits in C#

I'm working on optimizing a program I'm working on, which currently reads byte data using lock bits, but writes pixel data using setPixel. So how do I actually modify the pixel data that I'm reading in? If I try setting pp, cp, or np, the method…
vkoves
  • 149
  • 3
  • 9
3
votes
4 answers

Visual Studio 2012 - vshost32-clr2.exe has stopped working

I'm creating a WinForm Application in C# using Visual Studio 2012 and I'm getting an error when I debug it : vshost32-clr2.exe has stopped working I already searched but most results are for Visual Studio 2010 and lower and I get similar solutions…
CudoX
  • 985
  • 2
  • 19
  • 31
3
votes
1 answer

.Net getting RGB values from a bitmap using Lockbits

I am using the below code to extract RGB values from images, sometimes this works, however on certain files (seemingly where the Stride is not divisible by the width of the bitmap) it is returning mixed up values: Dim rect As New Rectangle(0, 0,…
Azza
  • 68
  • 1
  • 5
2
votes
1 answer

BitmapData and Marshal.Copy? What alternative for windows phone?

UPDATED: Been looking around and trying to figure out what alternative there is for windows phone 7.1 for BitmapData. I have Commented out the code in question. I am aware of Lockbits and that its fast in comparison to get set pixels and so on. As…
2
votes
2 answers

C# Move bitmap in picturebox

I create image with LockBits from array in cycle and scale to PictureBox.Width * n and Height: using (var bmp = new Bitmap(len, _height, PixelFormat.Format24bppRgb)) { var data = bmp.LockBits(new Rectangle(0, 0, len, _height),…
Kir
  • 155
  • 2
  • 10
2
votes
2 answers

What does LockBits/UnlockBits do in c#?

I have a method in c# that the only thing it does its LockBits, and then UnlockBits, and the images(input/output, transformed to byte arrays) are different. The one from output has less 100 and something bytes than the one from the input. This…
jlnc
  • 41
  • 1
  • 5
2
votes
1 answer

Improve speed of video correction algorithm based on locked bitmap, getpixel and optimized auxiliary functions

I wrote this code to remove annoying patterns in a video due to camera malfunction. The problem is that to encode a 2 Minute video this algorithm needs more than 2 hours. I want to significantly reduce the time needed. The algorithm iterates over…
Fabien Biller
  • 155
  • 1
  • 1
  • 10
2
votes
1 answer

C# Processing bmp images using Bitmap LockBits. Trying to change ALL the bytes, but values of some of them after saving remain 0. Why?

I need to use image processing with LockBits instead of GetPixel/SetPixel to decrease the processing time. But in the end it saves not all changes. Steps to reproduce the problem: Read all the bytes from initial bmp file; Change all these bytes and…
2
votes
1 answer

Check page access conditions for MifareUltralight NFC tags on Android

I already locked specific pages after I wrote one time to a MifareUltralight tag. When I call the writePage() the next time, I want to check the access conditions for that page first. If the page is locked, I do not want to call the write method.…
Minn Thein
  • 81
  • 3
2
votes
1 answer

Android: Error when resetting Dynamic locks on NFC NTAG213 (28h)

I am using NFCA.transceive to write to NTAG213 and can successfully write to location 28h that holds the dynamic locks without any problems when the tag is empty. But when I try to write it back to its default state I get a TAG_LOST exception. All…
ZipNFC
  • 489
  • 1
  • 6
  • 16
2
votes
2 answers

C# How do I convert my get GetPixel / SetPixel color processing to Lockbits?

EDIT: I deeply appreciate the replies. What I need more than anything here is sample code for what I do with the few lines of code in the nested loop, since that's what works right in GetPixel/SetPixel, but also what I can't get to work right…
MaoTseTongue
  • 71
  • 2
  • 8
2
votes
1 answer

Make Read Only access for Mifare UltraLight using Android

I can write my data on card successfully. I want that no one can write on my card, but that they can only read. Is this possible to achieve? Or is there any key where I can assign some password protection before writing data on my card? To write…
Bhoomika Brahmbhatt
  • 7,404
  • 3
  • 29
  • 44
2
votes
2 answers

Fast Bitmap modifying using BitmapData and pointers in C#

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…
Majak
  • 1,543
  • 1
  • 14
  • 28