Print Page | Close Window

Blitting into Screen

Printed From: Mirage Source
Category: Tutorials
Forum Name: Approved Tutorials
Forum Discription: All tutorials shown to actually work with MSE are moved here.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=51
Printed Date: 20 December 2006 at 6:01pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Blitting into Screen
Posted By: Sync
Subject: Blitting into Screen
Date Posted: 07 February 2006 at 6:29pm
Originally posted by william

Just got inspired by Fox tutorial, so i thought on making a small follow up:

Difficulty: 3/5 (due to my lazy explaining)

To blit things onto the picscreen you can use:

Public 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


Which is easier to use in my opinion. But then you need to load a tileset to into a picture control. Here you have a example:

BitBlt frmMirage.picScreen.hdc, picx, picy, 32, 32, frmMirage.PictureControl.hdc, tempx, tempy, vbSrcCopy


Thats basicly a copy paste from my singleplayer engine, just changed some names on it. But the easiest thing to understand BitBlt is to stydu the Function.

You can also use:

Public Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean


To blit transparent tiles, ex:

Call TransparentBlt(frmMirage.picScreen.hdc, picx, picy, 32, 32, frmMirage.PictureControl.hdc, tempx, tempy, 32, 32, RGB(0, 0, 0))


Another way is to use the Image control, put it on the screen make it visible=false. Then on the top in the coding part add:

Dim NewElement As Integer


And in form_load put this:

NewElement = 1


And then to use it, use this code to load it:

Load Image1(NewElement)
Image1(NewElement).Visible = True


And to move it around use this:

Image1(NewElement).Top = Image1(NewElement).Top + 50

or:
Image1(NewElement).Left = Image1(NewElement).Left + 50


You get what I mean, this was just some ideas I wrote fast. Didnt have anything to do really.

Very nice tutorial Fox!



Replies:
Posted By: Sync
Date Posted: 07 February 2006 at 6:31pm
Approved.



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info