Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help me with this source. 2

Status
Not open for further replies.

daverudy

Programmer
Dec 3, 1999
2
0
0
US
Ok, if you can do this you not only have skill but exprience. i have yet to find a book or a person who can help me although i have seen it in .exe form.<br>
i need to take a bitmap file w/ several &quot;sprites&quot; in it going from left to right and upload it as one bitmap image (&quot;Picture1&quot;) and select settain sprites from the whole thing so i can use them as seprate pictures so i can save space by not having 5000 seperate pictures.<br>
<br>
btw im going to animate them but i think i have that part figured out yet.<br>
<br>
i have been pointed in sooooo many directions rangeing from &quot;bit blt&quot; to mid$ and left$ none of whice were very prosperous. so if you have some source w/ what i need in it or you can write it or explain it for me i would be very greatfull and do you a favor if you should hapen to need one.<br>
<br>
<br>
Dave
 
This is probably a really stupid question that just demonstrates my complete lack of understanding of the original post.<br>
<br>
But anyway: There's an animation control supplied - is that not any good to you?<br>
<br>
It does limit you to no-sound avi files or rle compressed avi files.<br>
<br>
Below is example text from VB help file.<br>
<br>
Mike<br>
<br>
The following example opens an .avi file by using the Open Dialog, and begins playing it automatically. To try the example, place an Animation control and a CommonDialog control on a form, and paste the code into the form's Declarations section. Run the example, and choose an .avi file to open.<br>
<br>
Private Sub Animation1_Click ()<br>
With CommonDialog1<br>
.Filter = &quot;avi (*.avi)¦*.avi&quot;<br>
.ShowOpen<br>
End With<br>
With Animation1<br>
.Autoplay = True<br>
.Open CommonDialog1.Filename<br>
End With<br>
End Sub <p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Hi Dave<br>
<br>
I know what you want to do. You could use the Paintpicture method but for speed and functionality you need to become familiar with BitBlt. Below is a very quick and dirty intro.<br>
<br>
BitBlt has the following declaration:<br>
<br>
Public Declare Function BitBlt Lib &quot;gdi32&quot; (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<br>
<br>
where<br>
<br>
hDestDC is the handle to the device context you want to BitBlt to - or, in English, a reference number to the object you want to draw on. It also means that you can only BitBlt to certain controls, i.e. ones which have an hDC, e.g. a Form, a PictureBox, a Frame, etc. You cannot BitBlt to an Image control.<br>
<br>
x and y are the X and Y co-ordinates of the destination - i.e. the top left corner of the picture you &quot;paste&quot; will be here. These are usually both 0 if you want to place the picture in the top left corner of the target but you needn't - you can choose to paste it anywhere in the image.<br>
<br>
nWidth and nHeight specify the size of the image to be pasted. This can be bigger or smaller than either the source or the target - so you can &quot;copy&quot; a piece from a picture and &quot;paste&quot; it anywhere in the target.<br>
<br>
hSrcDC is the hDC to the picture you want to BitBlt from. Same restraints and conditions as with the destination hDC (hDestDC).<br>
<br>
xSrc and ySrc are the co-ordinates from which you would like to start BitBlt-ing on the source picture. Again, these are usually 0, but in your case you will set them to the top-left corner of the picture you want to copy from within the larger image. Note that there are no Width or Height parameters which means that the part of the picture you copy cannot be resized (with this function - there are others which can do it).<br>
<br>
dwRop is a flag representing the Raster Operation - i.e. how it &quot;pastes&quot; the source into the destination. I've listed the ROps below. For the moment play with SRCCOPY.<br>
<br>
Private Const BLACKNESS = &H42<br>
Private Const DSTINVERT = &H550009<br>
Private Const MERGECOPY = &HC000CA<br>
Private Const MERGEPAINT = &HBB0226<br>
Private Const NOTSRCCOPY = &H330008<br>
Private Const NOTSRCERASE = &H1100A6<br>
Private Const PATCOPY = &HF00021<br>
Private Const PATINVERT = &H5A0049<br>
Private Const PATPAINT = &HFB0A09<br>
Private Const SRCAND = &H8800C6<br>
Private Const SRCCOPY = &HCC0020<br>
Private Const SRCERASE = &H440328<br>
Private Const SRCINVERT = &H660046<br>
Private Const SRCPAINT = &HEE0086<br>
Private Const WHITENESS = &HFF0062<br>
<br>
Now you have the tools. To play with with them you will need (at least) two PictureBox controls. Make sure that their AutoRefresh properties are set to True. I would also suggest setting the ScaleMode to Pixel (3) and the AutoResize to False after yoo have loaded pictures into the picture boxes (at design time).<br>
<br>
Try the following:<br>
<br>
BitBlt Pic1.hDC, 0, 0, 20, 20, Pic2.hDC, 5, 5, SRCCOPY<br>
Pic1.Refresh<br>
<br>
Note the Refresh - It's quite important.<br>
This should copy a 20x20 pixel area from Pic2 (starting 5 pixels in and 5 pixels down) to the top left corner of Pic1.<br>
<br>
Good Luck. If you need more samples I'll be glad to help.<br>
Ian
 
way to go Ian &lt;smile&gt;<br>
-ml<br>
<p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Have you check out the &quot;Microsoft PictureClip&quot; control - does exactly what you're after and it comes free with VB.
 
You're absolutely right, RustyG.<br>
<br>
There are some some other factors to take into consideration though. Firstly, the PictureClip control looks like a wrapper for BitBlt & StretchBlt and, as can be expected, the really nice bits were ignored. Secondly, the use of &quot;sprites&quot; usually implies some form of transparency, which means that BitBlt is going to have to be used anyway, so why bother to add an 80K control when you don't really need it. <br>
<br>
Should I need to store five or six images, I wouldn't bother with the overhead; should I need to store 5000 and not require transparency then PictureClip looks attractive. But then being a control-freak (as opposed to a Control-freak) - and aren't all programmers - I would hate to waste all the effort I put into the BitBlt routines! B-)<br>
<br>
-Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top