|
-
Jul 17th, 2000, 10:24 PM
#1
Thread Starter
Lively Member
Ok. I have some drawing code that like draws stuff using setpixelv, only its real slow, so I'm creating a backbuffer for drawing on quickly and then blitting it to the primary surface. Ok. When I do a CreateCompatibleDC on the primary display surface, it only gives me a DC of 1x1 monochrome. How can I resize this and change the pallete? All I need is a seperate memory surface to draw on using whatever method is a)possible and b)fastest. So there you go! Thanks.
(Oh and if you are really bored and or want to see what I need it for, download rts.ZIP and notice the slowness in the drawing. Yes, I am writing an RTS.)
-
Jul 17th, 2000, 11:52 PM
#2
Thread Starter
Lively Member
Ok I got the backbuffer running, it just doesnt work right. I wrote this chunk of code to test it but it just doesnt work. I took the declarations section out of the [*code] tag so that it wraps to the screen. Can you help me?
Dim BitDC As Long
Dim BackBuffer As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Const SRCAND = &H8800C6
Private Const SRCCOPY = &HCC0020
Private Const SRCERASE = &H440328
Private Const SRCINVERT = &H660046
Private Const SRCPAINT = &HEE0086
Code:
Private Sub Command1_Click()
Me.Cls
Dim i As Long
Dim i2 As Long
For i = 1 To 50
For i2 = 1 To 15
SetPixelV BackBuffer, i, i2 * 50, 255
Next
Next
BitBlt Me.hdc, 1, 1, 50, 50, BackBuffer, 1, 1, SRCCOPY
SetPixelV BackBuffer, i, i2 * 50, 255
Debug.Print GetPixel(BackBuffer, 1, 1)
Debug.Print GetPixel(BackBuffer, 15, 65)
Debug.Print GetPixel(BackBuffer, 65, 5)
End Sub
Private Sub Form_Load()
BackBuffer = CreateCompatibleDC(Me.hdc)
BitDC = CreateCompatibleBitmap(Me.hdc, 100, 100)
SelectObject BackBuffer, BitDC
End Sub
[Edited by Vuen on 07-18-2000 at 01:00 AM]
-
Jul 18th, 2000, 11:14 PM
#3
Thread Starter
Lively Member
Doesn't anybody know this?
-
Jul 20th, 2000, 10:34 PM
#4
Thread Starter
Lively Member
Ok I got it working finally. It works just fine. [sarcasm]Thanks everyone for trying to help.[/sarcasm] If anyone wants the code just ask.
-
Jul 21st, 2000, 03:37 AM
#5
Lively Member
Please, mail it to me! Thanks!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|