Click here to Skip to main content
15,902,299 members
Home / Discussions / C#
   

C#

 
GeneralRe: ICloneable class with strings Pin
WorkOnlineClick2Wealth8-May-16 5:46
WorkOnlineClick2Wealth8-May-16 5:46 
QuestionC# chart library with interactive elements drawing Pin
WallaceCheshire7-May-16 3:41
WallaceCheshire7-May-16 3:41 
AnswerRe: C# chart library with interactive elements drawing Pin
Ravi Bhavnani7-May-16 18:30
professionalRavi Bhavnani7-May-16 18:30 
AnswerRe: C# chart library with interactive elements drawing Pin
Kenneth Haugland7-May-16 18:31
mvaKenneth Haugland7-May-16 18:31 
QuestionWinForms issues: (partial rant, partial sharing, totally a request for opinions, comments) Pin
BillWoodruff7-May-16 2:21
professionalBillWoodruff7-May-16 2:21 
AnswerRe: WinForms issues: (partial rant, partial sharing, totally a request for opinions, comments) Pin
CHill607-May-16 4:45
mveCHill607-May-16 4:45 
QuestionWhat does Bitmap.LockBits() do? Pin
Bernhard Hiller5-May-16 21:04
Bernhard Hiller5-May-16 21:04 
AnswerRe: What does Bitmap.LockBits() do? PinPopular
OriginalGriff5-May-16 21:54
mveOriginalGriff5-May-16 21:54 
Ok...
LockBits effectively prevents the Garbage Collector from moving the data in memory - so pointers and so forth can be used directly instead of having to de-reference every time you wanted to use it. Because the GC is outside your direct control, if you don't use LockBits then the data you are pointing at can be "moved" in memory at will, rendering your pointers invalid. But it doesn't copy the memory - it just locks it in place.

Your data may be 3 bytes per pixel (i.e. has no Alpha channel) but that's inefficient to access: 32 bit quantities are a lot faster to throw around than 24 bit values, so your image is "padded" to 32bits with a default "solid" alpha channel.

stride is 4*2736 because it's a bytes count, rather than a pixel count - and a pixel is a 32 bit quantity (ARGB, with each "part" occupying a byte). So each row in your image of 2736 pixels takes stride bytes - i.e. to advance from one row in your rectangle to the same relative position in the next row means advancing by the width of your image, not the width of your rectangle:
-------------------
|C   ------       |
|D   |A   |E      |
|    |B   |       |
|    ------       |
|                 |
-------------------
If C is (0,0) on your image, and D is (0,1); A is (0,0) in your rect, and B is (0,1) in your rect (A is (5,1) in your image, B is (5,2)) then to move from the memory byte starting the rect A to the memory byte starting rect B, means adding the number of bytes in a whole row of the image - adding the bytes in the rect width would move you to E instead.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

GeneralRe: What does Bitmap.LockBits() do? Pin
Bernhard Hiller5-May-16 23:22
Bernhard Hiller5-May-16 23:22 
GeneralRe: What does Bitmap.LockBits() do? Pin
OriginalGriff5-May-16 23:45
mveOriginalGriff5-May-16 23:45 
GeneralRe: What does Bitmap.LockBits() do? Pin
Rob Philpott6-May-16 5:49
Rob Philpott6-May-16 5:49 
GeneralRe: What does Bitmap.LockBits() do? Pin
OriginalGriff6-May-16 6:12
mveOriginalGriff6-May-16 6:12 
Questionenvt Pin
Member 125041034-May-16 23:52
Member 125041034-May-16 23:52 
AnswerRe: envt Pin
Eddy Vluggen5-May-16 0:06
professionalEddy Vluggen5-May-16 0:06 
AnswerRe: envt Pin
Pete O'Hanlon5-May-16 0:08
mvePete O'Hanlon5-May-16 0:08 
AnswerRe: envt Pin
Richard MacCutchan5-May-16 0:28
mveRichard MacCutchan5-May-16 0:28 
AnswerRe: envt Pin
Sascha Lefèvre5-May-16 0:44
professionalSascha Lefèvre5-May-16 0:44 
AnswerRe: envt Pin
Patrice T5-May-16 0:54
mvePatrice T5-May-16 0:54 
AnswerRe: envt Pin
koolprasad20035-May-16 18:58
professionalkoolprasad20035-May-16 18:58 
Questionc# Pin
Member 125041034-May-16 22:03
Member 125041034-May-16 22:03 
AnswerRe: c# Pin
Richard MacCutchan4-May-16 22:56
mveRichard MacCutchan4-May-16 22:56 
QuestionRe: c# Pin
Member 122800337-May-16 4:42
Member 122800337-May-16 4:42 
AnswerRe: c# Pin
Richard MacCutchan7-May-16 5:08
mveRichard MacCutchan7-May-16 5:08 
Questionc# Pin
Member 125041034-May-16 21:59
Member 125041034-May-16 21:59 
AnswerRe: c# Pin
Simon_Whale4-May-16 22:03
Simon_Whale4-May-16 22:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.