![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Questions & Help Needed Post any question regarding Basic4ppc. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi Guys,
Any help would be great. ![]() How can I do the following: PictureBox Arrays: Bug(0) to Bug(7) for i = vaderst to vaderfin bug(i).Left = looperx:Bug(i).Top = loopery next Image Arrays: imaBugSplat(0) to imgBugSplat(7) Bug(BKI) = imgBugSplat(KI) '<---KILLS BUGS DEAD I am also having trouble with this line: Randomize Val(Right(Time$, 2)) / 3.17412 Line's and Shapes's were easy to convert: pen1.Color = cGold line(160,150,160,350) Sub Line(x1,y1,x2,y2) drawer.DrawLine(pen1.Value,x1,y1,x2,y2) drawer.Refresh(x1-x2,y1-y2,x1-x2,y1-y2) End Sub Can we Use/Create VB6 Class Modules Is their an equivelent of the following: 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 Thanks in advance, Andrew. |
|
|||
|
Hi Erel,
Thank you for your speedy and helpfull responce. The code samples you provided work a treat. The Randomize statement is used to generate randome enemy fire by setting and resetting the tmrTimer_EnemyFire Subroutine. Any chance that you or one of your many Library coders could create a Basic4ppc bitblt dll? ![]() Thanks again. Regards, Andrew |
|
|||
|
Hi again Erel,
Please find below as requested! BitBlt quite simply makes copies of portions of the screen. This is done by accessing the Windows hDC and other low level mind numbing things. This is similar to your: drawer.New1("Form1",true) rectSrc.New1(0,0,bmp.Width,bmp.Height) 'The source rectangle. rectDest.New1(120,120,36,32) drawer.DrawImage1(bmp.Value,rectSrc.Value,rectDest .Value,true) Form1.DrawString("Try to catch the smiley",12,10,10,200,50,cBlack) It is a very fast routine, you dont get the flickering as you do in tha above routine This has been on the go since VB3 and I still use it in VB6: Declare the functions that are in the GDI32.DLL file so we can use them in VB.NET. Declare Auto Function BitBlt Lib "GDI32.DLL" ( _ ByVal hdcDest As IntPtr, _ ByVal nXDest As Integer, _ ByVal nYDest As Integer, _ ByVal nWidth As Integer, _ ByVal nHeight As Integer, _ ByVal hdcSrc As IntPtr, _ ByVal nXSrc As Integer, _ ByVal nYSrc As Integer, _ ByVal dwRop As Int32) As Boolean Private Function copyRect(ByVal src As PictureBox, _ ByVal rect As RectangleF) As Bitmap 'Get a Graphics Object from the form Dim srcPic As Graphics = src.CreateGraphics 'Create a EMPTY bitmap from that graphics Dim srcBmp As New Bitmap(src.Width, src.Height, srcPic) 'Create a Graphics object in memory from that bitmap Dim srcMem As Graphics = Graphics.FromImage(srcBmp) 'get the IntPtr's of the graphics Dim HDC1 As IntPtr = srcPic.GetHdc 'get the IntPtr's of the graphics Dim HDC2 As IntPtr = srcMem.GetHdc 'get the picture BitBlt(HDC2, 0, 0, rect.Width, _ rect.Height, HDC1, rect.X, rect.Y, 13369376) 'Clone the bitmap so we can dispose this one copyRect = srcBmp.Clone() 'Clean Up srcPic.ReleaseHdc(HDC1) srcMem.ReleaseHdc(HDC2) srcPic.Dispose() srcMem.Dispose() srcMem.Dispose() End Function Then all we need to do is call the function to return the image we want: Dim bmp = CType(copyRect(src, _ New RectangleF(0, 0, 50, src.Height)), Bitmap) dest.Image = bmp.CloneShorthand: -or- dest.Image = CType(copyRect(src, _ New RectangleF(0, 0, 50, src.Height)), Bitmap).Clone Regards, Andrew. |
|
||||
|
Thanks.
Maybe I will get to it later. However if anyone is interested in building such a library it shouldn't be too complicated. Alex Yakhnin blog has a post about it: Alex Yakhnin - Creating a screen snapshot in CF v2. |
|
||||
|
Quote:
.... there is some hidden twist that I don't presently understand. having obtained the hdcs for a couple of .NET Bitmaps I can BitBlt BLACKNESS and WHITENESS onto the destination bitmap but even thought BtBlt returns true (success) it won't pick up the contents of the source bitmap for SRCCOPY and the other SRC... raster ops. I have no idea why I'll look again tomorrow - my brain's hurting! |
|
||||
|
Quote:
How about this one: Can you write a program that receives some code and checks if this code always stop? http://en.wikipedia.org/wiki/Halting_problem |
|
|||
|
agraham,
It seems that you have taken up the bitblt challenge! ![]() Find below the site I use for code snippets, it has another article on bitblt which may solve the problem you are finding! CodeProject: Using BitBlt to Copy and Paste graphics. Free source code and programming help This link has the code example and a demo project, the code is related to my earlier post. If you have a problem let me know. Regards, Andrew. |
|
||||
|
Lots of problems interoperating from GDI+ to GDI which explains the odd behaviour I have observed while experimenting. INFO: Interoperability Between GDI and GDI+. The key paragraph is "Using GDI on a GDI+ Graphics Object Backed by a Bitmap"
A concise summary of a highly technical situation. An hDC from a .NET Graphics for a Bitmap created by Graphics.FromImage(Bitmap) is effectively write-only as the underlying bitmap is not initialised. Therefore you can draw on it but not use it as a source. An hDC from a .NET Graphics for a Control created by Control.CreatGraphics().GetHdc() is both readable and writeable as a physical bitmap exists on the screen. Therefore BitBlt can be used for screen capture using the SRCCOPY rasterop to a destination bitmap and for very little else as the combinatorial rasterops do not have a destination to read. For this reason the the BitBlt way of achieving tranparency and animation won't work as it relies on the combinatorial rasterops SRCAND and SRCPAINT ![]() GDI gurus may have a way round this but I am afraid that I don't know enough about GDI (and don't want to learn either) so I'll have to give up for now. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Converting date to ticks value | mozaharul | Questions & Help Needed | 3 | 10-22-2008 09:51 AM |
| Have a look to the project and please correct me. | mozaharul | Questions & Help Needed | 2 | 10-13-2008 03:02 AM |
| Problem Converting CSV to SQLite | tcgoh | Questions & Help Needed | 5 | 11-01-2007 02:50 AM |
| Battery Saver project | Cableguy | Questions & Help Needed | 1 | 07-12-2007 07:02 PM |
| specifying datatypes when converting table to SQLite DB | Steve | Questions & Help Needed | 1 | 06-14-2007 04:56 AM |