![]() |
| | #1 |
| Super Moderator Join Date: Aug 2001
Posts: 7,817
| Fast way to blit between bitmaps Bitmap.Clone() runs out of memory after 30 images. I need to create hundreds of tiles from a larger image. All the examples I've found use LockBits which requires some unmanaged pointers. Not that I don't like pointers but dealing with them in C# does not look fun and the Marshal class appears to only copy much like memcpy does. So it's not possible to specify a rectangle nor control the areas it copies unless I copy one scan line at a time. |
| Bubba is offline | |
| | #2 |
| Super Moderator Join Date: Aug 2001
Posts: 7,817
| Well since no one seems to have a better solution yet I'm going to code a C++ module that uses inline assembly to do the copying and then create an ATL COM DLL so I can use it easily in C#. |
| Bubba is offline | |
| | #3 |
| Cat without Hat Join Date: Apr 2003
Posts: 8,492
| Hmm ... doesn't the GDI+ have some blitting functions? It's from DC to DC, but memory DCs work well.
__________________ All the buzzt! CornedBee"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code." - Flon's Law |
| CornedBee is offline | |
| | #4 |
| Sweet Join Date: Aug 2002 Location: Tucson, Arizona
Posts: 1,698
| Maybe something like this Bubba. http://msdn2.microsoft.com/en-us/lib...fromimage.aspx |
| prog-bman is online now | |
| | #5 |
| Super Moderator Join Date: Aug 2001
Posts: 7,817
| Nah that creates a graphics object from an image. I'm using that to create a graphics object from my bitmap which represents the screen. Similar to creating a memory DC and then blitting from that to the client DC. I've nearly completed the assembly code but I'm so rusty at it. My main problem is when doing a rep movsd if the length in ecx is not evenly divisible by 4 (the size of a DWORD) then some bytes are left. I think a simple and operation followed by a rep movsb ought to do the trick to get the remaning bytes. |
| Bubba is offline | |
| | #6 |
| Sweet Join Date: Aug 2002 Location: Tucson, Arizona
Posts: 1,698
| So something like this wouldn't work for you Bubba Code: protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
//Load a bitmap and create a new one to draw a sub bitmap
Bitmap greenRed = (Bitmap)Bitmap.FromFile("greenred.bmp");
Bitmap destImage = new Bitmap(20, greenRed.Height);
//Grab the drawing surface for the new image
Graphics destGraphics = Graphics.FromImage(destImage);
//Draw the old one into the new ones smaller space
destGraphics.DrawImage(greenRed, 0, 0);
//Draw both on the screen
e.Graphics.DrawImage(greenRed, new Point(0, 0));
e.Graphics.DrawImage(destImage, new Point(100,0));
}
|
| prog-bman is online now | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Drawing bitmaps efficiently | scwizzo | Windows Programming | 28 | 06-30-2009 08:25 PM |
| DX9 Not Displaying Bitmaps | Sentral | Game Programming | 9 | 01-31-2006 05:35 AM |
| MFC: Multiple clicks shows multiple bitmaps - how? | BrianK | Windows Programming | 0 | 06-20-2004 07:25 PM |
| textprintf - how to blit it? | GaPe | Game Programming | 5 | 05-04-2003 03:22 AM |
| using standard bitmaps in the toolbar editor | Kibble | Windows Programming | 0 | 12-23-2002 08:43 PM |