473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Lockbits vs BitBlt

_DD
I've heard that fast bitblt functions still need to resort to calling
older Bitblt vs interop. Has this changed? Will GDI+ Lockbits come
close to the speed of GDI BitBlt?
Jan 12 '07 #1
3 8798
The two principles are totally different.

BitBlit and incidentally DrawImage is for copying an image in memory to
the graphics object. Either a graphics device such as a screen or a
second in-memory graphics object.

LockBits enables direct access to the image byte array without the need
to go through the less efficient bitmap image APIs. Access in this way
is fast and unsubtle.

Where LockBits even approaches the philosophy of BitBlit is when a
direct image to image copy operation is needed. In this case LockBits
may be used to access both memory buffers and data transferred from one
to the other. Any form of clever image processing in this transfer
begins to approach the inefficiency of DrawImage if any processing is
done on the image data.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

_DD wrote:
I've heard that fast bitblt functions still need to resort to calling
older Bitblt vs interop. Has this changed? Will GDI+ Lockbits come
close to the speed of GDI BitBlt?
Jan 12 '07 #2
_DD
On Fri, 12 Jan 2007 07:09:44 +0100, "Bob Powell [MVP]"
<bob@_spamkiller_bobpowell.netwrote:
>The two principles are totally different.

BitBlit and incidentally DrawImage is for copying an image in memory to
the graphics object. Either a graphics device such as a screen or a
second in-memory graphics object.

LockBits enables direct access to the image byte array without the need
to go through the less efficient bitmap image APIs. Access in this way
is fast and unsubtle.
I didn't explain the intent very well. A closer analogy would have
been 'DibSection + BitBlt' vs 'LockBits + DrawImageUnscaled.'
I'm thinking about revisiting an app that I worked on ages ago in olde
C++ (seems way too long ago).
>Where LockBits even approaches the philosophy of BitBlit is when a
direct image to image copy operation is needed. In this case LockBits
may be used to access both memory buffers and data transferred from one
to the other.
That's about it. The app basically builds a screen behind the scenes
by stamping graphics images into ram, cookie-cutter style. Envision
something like an schematic cad system with preset resistor and
capacitor symbols in monochrome bit patterns. Not an animation, per
se, but I need to do a complete BitBlt on a large window.

If memory serves, I was using DibSections and/or a 'magic'
undocumented ROP, 0xE20746, which does the cookie cutter thing quite
efficiently (Not sure why that was not documented).

In the interim, I've written some C# code where I had to do something
vaguely like that. I ended up using Lockbits to access ram and stamp
the pattern, then DrawImageUnscaled() to blt it.

I've heard that to get sufficient speed that C# programmers are still
Interop'ing older Dibsection/BitBlt calls. Can LockBits get close to
that speed? Maybe I should just be thinking DirectX, but this is
almost like a schematic cad program, not a game.

[re Lockbits]
Any form of clever image processing in this transfer
begins to approach the inefficiency of DrawImage if any processing is
done on the image data.
You got me there. I thought that would be the fast part.
Jan 12 '07 #3
_DD
On Fri, 12 Jan 2007 00:27:02 -0800, TheMadHatter
<Th**********@discussions.microsoft.comwrote:
>using LockBits and unsafe code:
Is it suppose to actualy lock the data in memory???????

I found out the bitter way that it is safer to create the
bitmap data, pin it, and wrap the bitmap class around it.
That way it was ptr safe. LockBits alone isnt "safe".

What the lockBits for then?????
Is it simular to lock(someObj) ???????
It will be interesting to hear what Bob says about that, but I thought
LockBits was supposed to do something like what you described above.
However, I do have an app that uses LockBits where the display
flatlines once in a while. I had NOT attributed that to LockBits or
memory reallocation, but it's so sporadic that it's tough to trace
(does not happen under the debugger).

Do you have places where you know that Lockbits has failed to keep ram
from being moved?

Jan 12 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DraguVaso | last post by:
Hi, In the override of the Paint-method of a DataGridTextBoxColumn I want to show an image with BitBlt, to see what I can gain there on performance. The problem is: It doesn't show me the image...
5
by: JackS | last post by:
I am trying to use GDI32 bitblt to write a bitmap to a control's window, but all I get is an empty rectangle of some rop-dependent color. In short, I use the following logic in a paint event handler:...
0
by: Learner Net via .NET 247 | last post by:
(Type your message here) What I am trying to do is create a bit map image from scatch using the managed C++ LockBits method. I want to display the bit map as a result of a button click. I have...
7
by: VB Programmer | last post by:
I am using the BitBlt operation to capture various controls into jpegs. It's almost like a screen capture, but of just the control. (This is a VB.NET application.) Because of BitBlt limitations...
1
by: RT | last post by:
It was mentioned here that LockBits can sometimes be vulnerable to the GC. Though the implication of docs that I've seen regarding LockBits would imply that it is immune to the GC, I do have an app...
2
by: =?Utf-8?B?VGhlTWFkSGF0dGVy?= | last post by:
I dont know if I missed something in documentation, but I was having a problem with "Bitmap.LockBits" and was wondering if anyone else has discovered it too. According to everyones examples...
6
by: Martijn Mulder | last post by:
/* BitBlt.cs C# code using P/Invoke I have good reasons to use P/Invoke to get access to the Win32 API function BitBlt(). But I have trouble understanding the workings of it. Below is a...
1
by: =?Utf-8?B?Y3JhbmtlX2JveQ==?= | last post by:
Hi Folks, I'm not sure where this post belongs since I'm using managed vc.net, but the issue is around GDI BitBlt. Here is a summary of the problem: - I am trying to copy a bitmap of my main...
0
by: crankeboy | last post by:
Hi Folks, My setup: Visual Studio Express 2008, VC++, .NET, BitBlt Here is a summary of the problem: - I am trying to copy a bitmap of my main form into a picture box. - To do this, I bitblt...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.