Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Interface and Graphics > GDI+ Drawing on a bitmap created with GdipCloneBitmapArea


Reply
 
Thread Tools Display Modes
  #1  
Old 04-16-2012, 02:12 PM
mms mms is offline
Ultimate Contributor
 
Join Date: Jul 2002
Location: Hamilton, Ontario
Posts: 1,714
Default GDI+ Drawing on a bitmap created with GdipCloneBitmapArea


I need to be able to draw on a cloned bitmap, but nothing I tried works.

The code below draws the cloned bitmap successfully, but not the rectangle I draw on it.
(Even though status comes back OK in this line
stat = GdipFillRectangle(memGraphics, brush, 0, 0, 50, 50)
nothing is drawn on the cloned bitmap)

Any ideas?

Code:
    ' Create a brush object
    Dim brush As Long
    stat = GdipCreateSolidFill(&HFFFF00FF, brush)
    
    ' Create a SCREEN Graphics object
    Dim screenGraphics As Long
    stat = GdipCreateFromHDC(Picture1.hdc, screenGraphics)

    ' Create a MEMORY Graphics object for cloned bitmap
    Dim memGraphics As Long
    Dim clonedBitmap As Long
    stat = GdipCreateFromHDC(Picture1.hdc, memGraphics)
    stat = GdipCreateBitmapFromGraphics(100, 100, memGraphics, clonedBitmap)
    stat = GdipGetImageGraphicsContext(clonedBitmap, memGraphics)

    ' Create a Bitmap object from a JPEG file.
    Dim bitmap As Long
    stat = GdipLoadImageFromFile(StrConv(App.path & "\myBitmap.bmp", vbUnicode), bitmap)

    ' Clone a portion of the bitmap.
    stat = GdipCloneBitmapArea(0, 0, 100, 100, PixelFormatDontCare, bitmap, clonedBitmap)

    ' Draw on memory bitmap.
    stat = GdipFillRectangle(memGraphics, brush, 0, 0, 50, 50)

    ' Draw the cloned bitmap to screen
    stat = GdipDrawImage(screenGraphics, clonedBitmap, 0, 0)
Reply With Quote
  #2  
Old 04-16-2012, 02:23 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,862
Default

Don't you need to get your Graphics object to access the clonedBitmap after you've cloned it?
The original bitmap you were accessing with the Graphics object is where you probably tried to draw your rectangle, but you now have a new bitmap and need a graphics object for that one.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #3  
Old 04-16-2012, 02:45 PM
mms mms is offline
Ultimate Contributor
 
Join Date: Jul 2002
Location: Hamilton, Ontario
Posts: 1,714
Default

If this is what you are meaning, then now I get the magenta rectangle, but no image.

Code:
    ' Create a brush object
    Dim brush As Long
    stat = GdipCreateSolidFill(&HFFFF00FF, brush)
    
    ' Create a SCREEN Graphics object
    Dim screenGraphics As Long
    stat = GdipCreateFromHDC(Picture1.hdc, screenGraphics)

    ' Create a MEMORY Graphics object for cloned bitmap
    Dim memGraphics As Long
    Dim clonedBitmap As Long
    stat = GdipCreateFromHDC(Picture1.hdc, memGraphics)
    stat = GdipCreateBitmapFromGraphics(100, 100, memGraphics, clonedBitmap)
    stat = GdipGetImageGraphicsContext(clonedBitmap, memGraphics)

    ' Create a Bitmap object from a JPEG file.
    Dim bitmap As Long
    stat = GdipLoadImageFromFile(StrConv(App.path & "\myBitmap.bmp", vbUnicode), bitmap)

    ' Clone a portion of the bitmap.
    Dim memGraphics2 As Long
    Dim clonedBitmap2 As Long
    stat = GdipCloneBitmapArea(0, 0, 100, 100, PixelFormatDontCare, bitmap, clonedBitmap2)
    stat = GdipCreateFromHDC(Picture1.hdc, memGraphics2)
    stat = GdipCreateBitmapFromGraphics(100, 100, memGraphics2, clonedBitmap2)
    stat = GdipGetImageGraphicsContext(clonedBitmap2, memGraphics2)

    ' Draw on memory bitmap.
    stat = GdipFillRectangle(memGraphics2, brush, 0, 0, 50, 50)

    ' Draw the cloned bitmap to screen
    stat = GdipDrawImage(screenGraphics, clonedBitmap2, 0, 0)
Reply With Quote
  #4  
Old 04-16-2012, 02:53 PM
mms mms is offline
Ultimate Contributor
 
Join Date: Jul 2002
Location: Hamilton, Ontario
Posts: 1,714
Default

I found this kb article:

http://support.microsoft.com/kb/299583

but since I don't understand NET, I don't understand what it is that they are trying to do.
Reply With Quote
  #5  
Old 04-16-2012, 04:15 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,862
Default

I have problems decoding the way GDI+ is being used from VB6 at times as well, and don't have the setup to test what I'm suggesting.
But, if I understand what your code is doing, I was thinking that something along the lines of this might work.
Code:
    ' Create a brush object
    Dim brush As Long
    stat = GdipCreateSolidFill(&HFFFF00FF, brush)
    
    ' Create a SCREEN Graphics object
    Dim screenGraphics As Long
    stat = GdipCreateFromHDC(Picture1.hdc, screenGraphics)

    ' Create a MEMORY Graphics object for cloned bitmap
    Dim memGraphics As Long
    Dim clonedBitmap As Long

    ' Create a Bitmap object from a JPEG file.
    Dim bitmap As Long
    stat = GdipLoadImageFromFile(StrConv(App.path & "\myBitmap.bmp", vbUnicode), bitmap)

    ' Clone a portion of the bitmap.
    stat = GdipCloneBitmapArea(0, 0, 100, 100, PixelFormatDontCare, bitmap, clonedBitmap)

    stat = GdipGetImageGraphicsContext(clonedBitmap, memGraphics)

    ' Draw on memory bitmap.
    stat = GdipFillRectangle(memGraphics, brush, 0, 0, 50, 50)

    ' Draw the cloned bitmap to screen
    stat = GdipDrawImage(screenGraphics, clonedBitmap, 0, 0)
I'm assuming the GdipCloneBitmapArea will return a bitmap object in clonedBitmap.
Then I'm assuming GdipGetImageGraphicsContext will return a Graphics object to allow you to access that bitmap.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #6  
Old 04-16-2012, 06:01 PM
mms mms is offline
Ultimate Contributor
 
Join Date: Jul 2002
Location: Hamilton, Ontario
Posts: 1,714
Default

That code works perfectly!!

As always, thank you.

Now I just have to incorporate into my main project, and hopefully that won't be a problem.

What I am doing is dragging around objects on the screen. I find as the
bitmap grows in size, the dragging of objects starts to lag behind the mouse movement.

I had resolved this in a previous thread (as you might remember) but I was always using a constant size bitmap.

Now however, because the master bitmap can grow to very large sizes,
as I drag objects around on the screen when the bitmap is large, the response time again gets unacceptably slow.

That is why I want to only update that portion of the bitmap that is displayed in the viewport like so:
- GdipCloneBitmapArea to grab only that portion visible in the viewport
- modify the cloned bitmap area only
- draw back this small cloned bitmap into large master memory bitmap
- flip master bitmap to screen

In this thread

http://www.xtremevbtalk.com/showthread.php?t=323783

You made this comment:
Quote:
The BufferedGraphics Buffer does not support opacity, so can only be the bottom layer (background) of whatever you may be accumlating (layering) on top of it.
It's sole purpose is to back an area of screen so that that area of the screen can be updated all at once. And by area of the screen, I mean the area behind a control. You can't force the BufferedGraphics to render anywhere, at any size, other than at the upper-left of a control and at whatever size the buffer is.
Is this saying that I am going about this all wrong, and can simply draw my objects over an already persistant bitmap that does not have to constantly be flipped to the screen?

Last edited by mms; 04-16-2012 at 06:07 PM.
Reply With Quote
  #7  
Old 04-16-2012, 09:55 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,862
Default

The BufferedGraphics class persitent bitmap is in memory so would have to be rendered to the screen.
In .Net this seems to be the fastest way to transfer a backbuffer to the screen.
If I modify a bitmap that a control is holding, and I have the control refresh itself, it seems to take several times longer than if I use the BufferedGraphics Buffer.
Apparently, this is because the BufferedGraphics class is using BitBlt to do the transfer.
Since you're working with VB6, I don't know if you would have the same issue.
It seems like you could use bitblt directly fairly easily for buffer transfer to the screen rather than use the BufferedGraphics class, which I thought was only there as an wrapper for managed code. I don't know if it is part of GDI+.
I'm not familiar enough with the raw GDI+ API to know. My GDI+ exposure has been through the Managed Class wrappers of .Net.

As for slowdown as the bitmap gets bigger, I'm not sure just what you are doing.
If only a portion of the bitmap is visible in the viewpont, then what is flipping the master bitmap to the screen doing.
Also you say you only modify the visible area, so it sounds like you don't have any need to update anything outside the viewport, and if that is true, then do you really need to clone a portion of the bitmap. Can't you modify the portion of the bitmap and then refresh the screen with that portion.
Most tile based games of course, don't build a hugh bitmap of their world, just assemble the visible portion based on the tile map.
If a bitmap starts to grow too large and become unwieldy, you may have to consider some sort of breaking the bitmap into multiple pieces so you don't deal with the whole bitmap at once.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #8  
Old 04-17-2012, 09:54 PM
mms mms is offline
Ultimate Contributor
 
Join Date: Jul 2002
Location: Hamilton, Ontario
Posts: 1,714
Default

Quote:
If only a portion of the bitmap is visible in the viewpont, then what is flipping the master bitmap to the screen doing.
Also you say you only modify the visible area, so it sounds like you don't have any need to update anything outside the viewport, and if that is true, then do you really need to clone a portion of the bitmap.
I keep the master bitmap updated, so that when I use the Scroll controls,scrolling will be instantaneous over an up-to-date master bitmap.

Quote:
Can't you modify the portion of the bitmap and then refresh the screen with that portion.
I thought that's what I was doing with GdipCloneBitmapArea.
I made a copy of only that part of the area inside the viewport, draw all dragging of objects on that, and then redraw only that portion into master bitmap.

Quote:
If a bitmap starts to grow too large and become unwieldy, you may have to consider some sort of breaking the bitmap into multiple pieces so you don't deal with the whole bitmap at once.
I thought about this, but will tackle that at a later time.

Quote:
Now I just have to incorporate into my main project, and hopefully that won't be a problem.
Spent all evening trying to do this, and can't get it working. I know I have all the required pieces of the puzzle, I just can't put them together.
I'll continue trying again tomorrow night.
Reply With Quote
  #9  
Old 04-20-2012, 09:19 PM
mms mms is offline
Ultimate Contributor
 
Join Date: Jul 2002
Location: Hamilton, Ontario
Posts: 1,714
Default

I've got this working (for the most part), but I am not convinced I am doing this in the most optimized manner.

I added timing code to see how quick (slow) this is.

Am I going about this the right way?

Three graphics call in MouseMove event while dragging an object.
Code:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)

    If Button = vbLeftButton Then
    
        ' Draw persistent background to dynamic canvas
        QueryPerformanceCounter Ctr1: QueryPerformanceCounter CtrR
        stat = GdipDrawImage(gfxMemCanvas, bmpMemBackgr, -HScroll1.value, -VScroll1.value)
        QueryPerformanceCounter Ctr2: QueryPerformanceCounter CtrR
        Debug.Print format(CtrR / Freq * 1000, "0.0") & " " & _
                    format((Ctr2 - Ctr1 - Overhead) / Freq * 1000, "0.00000") & _
                    " milliseconds GdipDrawImage bmpMemBackgr to gfxMemCanvas"
                    
        ' Draw dragged object (sprite) at new location on dynamic canvas
        QueryPerformanceCounter Ctr1: QueryPerformanceCounter CtrR
        stat = GdipDrawRectangle(gfxMemCanvas, pen, x, y, 200, 100)
        QueryPerformanceCounter Ctr2: QueryPerformanceCounter CtrR
        Debug.Print format(CtrR / Freq * 1000, "0.0") & " " & _
                    format((Ctr2 - Ctr1 - Overhead) / Freq * 1000, "0.00000") & _
                    " milliseconds GdipDrawRectangle to gfxMemCanvas"
                
        ' Draw dynamic canvas to screen
        QueryPerformanceCounter Ctr1: QueryPerformanceCounter CtrR
        stat = GdipDrawImage(gfxScr, bmpMemCanvas, -HScroll1.value, -VScroll1.value)
        QueryPerformanceCounter Ctr2: QueryPerformanceCounter CtrR
        Debug.Print format(CtrR / Freq * 1000, "0.0") & " " & _
                    format((Ctr2 - Ctr1 - Overhead) / Freq * 1000, "0.00000") & _
                    " milliseconds GdipDrawImage bmpMemCanvas to gfxScr"
        
        Picture1.Refresh
     
     End If
    
End Sub
Timing output
Code:
15617829.2 1.91225 milliseconds GdipDrawImage bmpMemBackgr to gfxMemCanvas
15617830.9 0.11789 milliseconds GdipDrawRectangle to gfxMemCanvas
15617837.3 5.05316 milliseconds GdipDrawImage bmpMemCanvas to gfxScr
15617842.9 1.91756 milliseconds GdipDrawImage bmpMemBackgr to gfxMemCanvas
15617844.7 0.08269 milliseconds GdipDrawRectangle to gfxMemCanvas
15617850.9 5.02913 milliseconds GdipDrawImage bmpMemCanvas to gfxScr
15617856.6 2.02484 milliseconds GdipDrawImage bmpMemBackgr to gfxMemCanvas
15617858.2 0.11985 milliseconds GdipDrawRectangle to gfxMemCanvas
15617864.9 5.51998 milliseconds GdipDrawImage bmpMemCanvas to gfxScr
15617870.5 2.08434 milliseconds GdipDrawImage bmpMemBackgr to gfxMemCanvas
15617872.1 0.11845 milliseconds GdipDrawRectangle to gfxMemCanvas
15617878.3 5.01712 milliseconds GdipDrawImage bmpMemCanvas to gfxScr
Reply With Quote
  #10  
Old 04-21-2012, 12:58 AM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,718
Default

GDI+ drawing is NOT hardware accelerated. If you want faster drawing either use GDI (BitBlt/StretchBlt etc) or DirectX.
__________________
Quis custodiet ipsos custodues.
Reply With Quote
  #11  
Old 04-24-2012, 04:27 PM
mms mms is offline
Ultimate Contributor
 
Join Date: Jul 2002
Location: Hamilton, Ontario
Posts: 1,714
Default

I wrote a test app using GDI to compare speed... WOW it's faster!!

Code:
work computer 
GDI+                60 fps
GDI+ optimized     100 fps
GDI                560 fps

home computer 
GDI+                35 fps
GDI+ optimized      45 fps
GDI                 26 fps
Problem with GDI... no antialiasing etc.

Also, what could be up with my home computer being so slow using GDI...
...something doesn't seem quite right??

Does DirectX offer antialiasing?
Reply With Quote
  #12  
Old 04-24-2012, 07:40 PM
hDC_0 hDC_0 is offline
Contributor

* Expert *
 
Join Date: Feb 2004
Posts: 537
Default no antialiasing with GDI?

Quote:
Originally Posted by mms
Problem with GDI... no antialiasing etc.
No anti-aliasing with GDI?

I'm sure someone named Dana Seaman would have to disagree:
"Anti-Alias 2D Engine (Line,Arc,Circle,Ellipse,Polygon). Pure Vb (NO dependencies)"

You might also want to check out this for anti-aliasing..
Quote:
The idea of an alpha channel is it stores how transparent a given pixel should be, from 0 (completely transparent) to 255 (completely opaque). Once this concept is in place it becomes easier to create much more sophisticated displays, in particular it allows for color-accurate drop-shadows and smoothing of anti-aliased edges against any background.
From:
vbAccelerator: Alpha DIBSections- Modify per pixel alpha in a bitmap
for drop-shadows and other exciting effects.

There is also a forum member named "eXeption" who posted some antialiasing code..just off the top of my head
this one and this one were interesting.
Plus he contributed some code in the Fractals thread (which also has some anti-aliasing going on I believe).

noi_max also used BillSoo's DMA class to implement per pixel color adjust in the pixel plotting thread.
The attachments in that thread are a little bit awkward because one had to be patched
and the other try to compare three methods instead of just showing how fast DMA can be,
so I adjusted the BillsClass attachment to comment out all the slow code
and just leave the fastest possible method.
(See attachment below).

This example really shows that DMA is the fastest way to do per pixel adjust,
(even though DIBs can sometimes be easier to work with when masking),
and I really wish more good examples of using DMA existed on the forum.

You can also check out some of the attachments in the FOW thread
where passel uses DMA for pixel adjusting there as well.
Attached Files
File Type: zip noi_max_per_pixel_adjust_using_Bills_Class.zip (22.0 KB, 17 views)

Last edited by hDC_0; 04-24-2012 at 07:48 PM.
Reply With Quote
  #13  
Old 04-25-2012, 08:29 AM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,718
Default

You should be able to use GDI+ antialiasing (to a memory bitmap) and then simply draw with GDI. Post the GDI test app, something is wrong if it's slower.

Quote:
Originally Posted by mms View Post
I wrote a test app using GDI to compare speed... WOW it's faster!!

Code:
work computer 
GDI+                60 fps
GDI+ optimized     100 fps
GDI                560 fps

home computer 
GDI+                35 fps
GDI+ optimized      45 fps
GDI                 26 fps
Problem with GDI... no antialiasing etc.

Also, what could be up with my home computer being so slow using GDI...
...something doesn't seem quite right??

Does DirectX offer antialiasing?
__________________
Quis custodiet ipsos custodues.
Reply With Quote
  #14  
Old 04-25-2012, 07:32 PM
mms mms is offline
Ultimate Contributor
 
Join Date: Jul 2002
Location: Hamilton, Ontario
Posts: 1,714
Default

Same code both computers, but my home computer executes it at a snail's pace.

Code:
Private Sub Command1_Click()

    bDone = Not bDone
    
    If bDone = True Then
        inc = 0
        t1 = GetTickCount
    End If
    
    Do While bDone = True
            
        DoEvents
                    
        inc = inc + 1
        
        ' Draw background to backbuffer
        ret = BitBlt(hBackbufferDC, 0, 0, _
                     788, 541, hBackgroundDC, 0, 0, SRCCOPY)

        ' Draw sprite mask to backbuffer
        ret = BitBlt(hBackbufferDC, inc - offsetX, inc - offsetY, _
                     183, 144, hSpriteMaskDC, 0, 0, MERGEPAINT)

        ' Draw sprite to backbuffer
        ret = BitBlt(hBackbufferDC, inc - offsetX, inc - offsetY, _
                     183, 144, hSpriteDC, 0, 0, SRCAND)

        ' Flip background to PictureBox
        ret = BitBlt(Form1.Picture1.hdc, 0, 0, _
                     788, 541, hBackbufferDC, 0, 0, SRCCOPY)
    
        ' Refresh PictureBox
        Form1.Picture1.Refresh

    Loop
    
    t2 = GetTickCount
    Debug.Print inc / ((t2 - t1) / 1000) & "frames per second"

End Sub
Don't know why code tags are not displaying entire block?

Last edited by mms; 04-25-2012 at 07:38 PM.
Reply With Quote
  #15  
Old 04-25-2012, 09:22 PM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,718
Default

Ticks aren't a reliable unit for measuring small intervals. I'd use QueryPerformanceCounter instead. Also, turn AutoRedraw off and rem out .Refresh and see how the computers compare then.
__________________
Quis custodiet ipsos custodues.
Reply With Quote
  #16  
Old 04-26-2012, 06:08 AM
mms mms is offline
Ultimate Contributor
 
Join Date: Jul 2002
Location: Hamilton, Ontario
Posts: 1,714
Default

Whoa... from 560 fps to 950 fps on my work computer, Ill check my home computer tonight.

I'm confused however. When I did as you instructed, I expected to see no image, but only get the frames per second calculation.

Instead, the background and moving sprite are both displayed... Why?

Manual display and dragging of sprite is not possible however.
Reply With Quote
  #17  
Old 04-26-2012, 09:16 AM
OnErr0r's Avatar
OnErr0r OnErr0r is offline
Obsessive OPtimizer

Administrator
* Guru *
 
Join Date: Jun 2002
Location: Debug Window
Posts: 13,718
Default

Autoredraw is only useful for (easy) image persistance. You can persist the image yourself by redrawing it in the paint event. Persistance isn't necessary when you're drawing a sprite as it's constantly being redrawn anyway.

Autoredraw is gone in .net, so you might as well get used to doing it yourself as you will eventually anyway.
__________________
Quis custodiet ipsos custodues.
Reply With Quote
  #18  
Old 04-26-2012, 03:28 PM
mms mms is offline
Ultimate Contributor
 
Join Date: Jul 2002
Location: Hamilton, Ontario
Posts: 1,714
Default

A whopping increase from 26 fps to 32 fps.

My home computer doesn't have hardware accelaration?

Even so, this wouldn't explain why home computer executes GDI+ code faster than GDI code?
Reply With Quote
  #19  
Old 04-26-2012, 03:48 PM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default

Quote:
Originally Posted by mms
Manual display and dragging of sprite is not possible however.
Why not?
Because you are using DMA to anti-alias the sprite instead of using just masked Bitblt?
You should be able to Bitblt the background of that will be behind the sprite into a backbuffer
and then Bitblt the sprite onto the background,
perform the anti-aliasing (with DMA or some GDI+ code),
then blit the background with anti-aliased sprite back to the main canvas. (picturebox?)
Quote:
Originally Posted by mms
Even so, this wouldn't explain why home computer executes GDI+ code faster than GDI code?
There must be some hardware differences between the two machines.
Please give details on the hardware differences.
Reply With Quote
  #20  
Old 05-03-2012, 08:29 AM
mms mms is offline
Ultimate Contributor
 
Join Date: Jul 2002
Location: Hamilton, Ontario
Posts: 1,714
Default

Quote:
You should be able to use GDI+ antialiasing (to a memory bitmap) and then simply draw with GDI.
I'm trying this but can't get it working.

In the code below I have both methods (GDI & GDI+) rendering simultaneously.
Code:
Private Sub GraphicsRender()

    ' Render using GDI+
    
        ' Draw the background to the screen
        stat = GdipDrawImageRectRect(graphics, bmpBkgrnd, _
                                     0, 0, 788, 541, 0, 0, 788, 541, UnitPixel, 0)
    
        ' Draw the sprite to the screen
        stat = GdipDrawImageRectRect(graphics, bmpSprite, _
                                     spriteX, spriteY, 183, 144, 0, 0, 183, 144, UnitPixel, ia)
    
        ' Refresh PictureBox
        Picture1.Refresh

    ' Render using GDI

        ' Draw background to backbuffer
        ret = BitBlt(hBackbufferDC, 0, 0, 788, 541, hBackgroundDC, 0, 0, SRCCOPY)

        ' Draw sprite mask to backbuffer
        ret = BitBlt(hBackbufferDC, spriteX, spriteY, 183, 144, hSpriteMaskDC, 0, 0, MERGEPAINT)

        ' Draw sprite to backbuffer
        ret = BitBlt(hBackbufferDC, spriteX, spriteY, 183, 144, hSpriteDC, 0, 0, SRCAND)

        ' Flip background to PictureBox
        ret = BitBlt(Form1.Picture1.hdc, 0, 0, 788, 541, hBackbufferDC, 0, 0, SRCCOPY)

        ' Refresh PictureBox
        Form1.Picture1.Refresh

End Sub
Anything I do in trying to meld the two together causes a crash.

Suggestions?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->