Naveen
Naveen

Reputation: 6008

what's the difference between GdipBitmapLockBits and CreateDIBSection

GdipBitmapLockBits works on pBitmaps, requires locking ?
CreatDIBSection gives you a DIBsection, doesn't require locking ?

which method is better for working with raw pixel data ?
Here are two implementations for finding the difference between two images using each method.

Upvotes: 0

Views: 896

Answers (2)

Hans Passant
Hans Passant

Reputation: 942408

I won't expect any difference. The "lock" is just there to avoid the access violation you'd get when you close the memory mapped file and use the pointer to the bitmap data afterward.

The real cost is going to be in the code you run that whacks the bitmap bits.

Upvotes: 1

Jerry Coffin
Jerry Coffin

Reputation: 490713

These pieces, by themselves, aren't enough different to care much about. Mostly it comes down to a question of whether the rest of your code is using GDI or GDI+. If you're using GDI+, you might as well use gdipBitmapLockBits. If the rest of your drawing code just uses GDI, then you might as well use CreateDIBSection.

Upvotes: 2

Related Questions