Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Blt-ing Images onto the PicScreen via Code [By: MrMiguu]


mrmiguu
 Share

Recommended Posts

**[Intro]**
This tutorial will help you figure out how to _Blt_ images saved in _.BMP_ files onto your _picScreen_. If you don't know what any of that meant, then you're probably not ready to start using this method of graphical mainstream processing.
**[Note]**
If you currently add _GUI_ to your game and use stuff like [VB6]_Picture Boxes_ and [VB6]_Images_ and you're finding that they come out ugly or just take up too much space on your _frmMirage Form_, then this is the code for you!

::::::::::::::::::::::::::::::::
:: This is all client-sided ::
::::::::::::::::::::::::::::::::

**[Step: 1]**
Look into your client's source code for the _Module_ named **modDirectX** and add these lines at the top, below the _Option Explicit_
```
Public DD_TestImageSurf As DirectDrawSurface7
Public DDSD_TestImage As DDSURFACEDESC2
```
**[Step: 2]**
In that same _Module_, add these lines of code at the bottom of the _Sub_ named **InitSurfaces**
```
' Init Test Image ddsd type and load the bitmap
    DDSD_TestImage.lFlags = DDSD_CAPS
    DDSD_TestImage.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY
    Set DD_TestImageSurf = DD.CreateSurfaceFromFile(App.Path & "\GUI\TestImage.bmp", DDSD_TestImage)
    SetMaskColorFromPixel DD_TestImageSurf, 0, 0
```**SetMaskColorFromPixel DD_TestImageSurf, 0, 0**
The two 0's mean that the transparent color on the image will be the very top left corner pixel's color. Change these around to where ever you would like the transparent color pixel to be.

**[Step: 3]**
In the very same _Module_, add these lines anywhere within the confines of **modDirectX**
```
Sub BltTestImage(ByVal X As Long, ByVal y As Long)
    rec.Top = 0
    rec.Bottom = 64 ' You would replace this number with the Height of the image
    rec.Left = 0
    rec.Right = 64 ' You would replace this number with the Widther of the image

    Call DD_BackBuffer.BltFast(X, y, DD_TestImageSurf, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End Sub
```
**[Step: 4]**
Lastly, you would add this single line of code in the _Module_ named **modGameLogic** inside the _Sub_ named **GameLoop** above the line **TexthDC = DD_BackBuffer.GetDC**
```
Call BltTestImage(100, 50)
```NOTE - You can change the 100 and 50 to where ever you want the image to display on your screen.
The 100 operates as the X-axis and the 50 operates as the y-axis.

**[Step: 5]**
If you're too lazy to make your own, download this _image_ and reformat it to a _.BMP_ file, then save it inside your _GUI_ folder in your client and name it **TestImage**
![](http://i2.photobucket.com/albums/y23/Alexanderthegreat91/MiguuBox.png)

NOTE - If all else fails, make your own .BMP image and make sure to name it **TestImage**

[NO CREDIT GOES TO ME SINCE I DID NOT INVENT CODE, NOR DID I INVENT ECLIPSE OR EVEN VB6] - Amazing, huh?
Link to comment
Share on other sites

@[SB:

> Azure link=topic=56700.msg599757#msg599757 date=1263799743]
> The menu I made for Kinjiru will rape his full screen mode with this. :P As well as the menu for my game. Thanks so much Mr. Miguu.
>
> Edit: OH! Hey you didn't explain how this makes a color transparent?

Thank you. I just fixed it into there.
Link to comment
Share on other sites

```
SetMaskColorFromPixel DD_TestImageSurf, 0, 0
```
That doesn't set the mask colour as white, it reads the colour from a pixel in the surface and sets that as the mask colour. In this case it sets the mask colour to whatever colour you have in the 0, 0 pixel. (The top left pixel)
Link to comment
Share on other sites

@Robin:

> ```
> SetMaskColorFromPixel DD_TestImageSurf, 0, 0
> ```
> That doesn't set the mask colour as white, it reads the colour from a pixel in the surface and sets that as the mask colour. In this case it sets the mask colour to whatever colour you have in the 0, 0 pixel. (The top left pixel)

Oh yea. Haha. I looked stupid there for a minute. Yea, a mistake of mine. I will fix that immediately. I thought it sounded weird.
Link to comment
Share on other sites

@Timmah:

> Sorry to be a noob, but I really don't understand what this does?

@MrMiguuâ„¢:

> **[Intro]**
> This tutorial will help you figure out how to _Blt_ images saved in _.BMP_ files onto your _picScreen_. **If you don't know what any of that meant, then you're probably not ready to start using this** method of graphical mainstream processing.
Link to comment
Share on other sites

@MrMiguuâ„¢:

> @Timmah:
>
> > Sorry to be a noob, but I really don't understand what this does?
>
> @MrMiguuâ„¢:
>
> > **[Intro]**
> > This tutorial will help you figure out how to _Blt_ images saved in _.BMP_ files onto your _picScreen_. **If you don't know what any of that meant, then you're probably not ready to start using this** method of graphical mainstream processing.

I like how you think. o_O
Link to comment
Share on other sites

@Timmah:

> @[SB:
>
> > Azure link=topic=56700.msg601883#msg601883 date=1264279642]
> > If you don't know what it does, it's too advanced for you.
>
> I asked what it was, not if it I could do it or not.

Whats the point of doing it if you do not know what it does?
Link to comment
Share on other sites

@MrMiguuâ„¢:

> @Timmah:
>
> > @[SB:
> >
> > > Azure link=topic=56700.msg601883#msg601883 date=1264279642]
> > > If you don't know what it does, it's too advanced for you.
> >
> > I asked what it was, not if it I could do it or not.
>
> Whats the point of doing it if you do not know what it does?

The question is not rather I can do it or not.  is it so hard just to tell me what this does?
Link to comment
Share on other sites

/face palm.

:rolleyes: We are trying to tell you that he already explained what it does. If you don't understand the first post then you aren't ready to attempt this because it will be "very hard" and you will not know how to use it right.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...