Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Verrigans Image System
#1
Difficulty: 4/5
This isnt of super difficulty, but if you need any help, the thing i will tell you to download comes with a nice help file. Btw, im only giving the code for loading one of the surfaces, you cna mod it to fit the rest.


Download this:
http://www.verrigan.net/bitmaputils/VWBitmapUtils.zip

Now open your client, go into the reference menu (Project->References)

Now for the code to load, tiles, and the breakdown

In modDirectX at the top of initsurfaces() add

Code:
Dim DC As Long

Dim BMUtil As BitmapUtils

Set BMUtil = New BitmapUtils




Heres the code for the tiles:

Code:
' Init tiles ddsd type and load the bitmap
    Call BMUtil.LoadByteData(FileName & "tiles" & GFX_EXT)
    Call BMUtil.DecryptByteData("47dn45")
    Call BMUtil.DecompressByteData
    With DDSD_Tile
        .lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
        .ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_VIDEOMEMORY
        .lWidth = BMUtil.ImageWidth
        .lHeight = BMUtil.ImageHeight
    End With
    Set DD_TileSurf = DD.CreateSurface(DDSD_Tile)
    DC = DD_TileSurf.GetDC
    Call BMUtil.Blt(DC)
    Call DD_TileSurf.ReleaseDC(DC)
    DD_TileSurf.SetColorKey DDCKEY_SRCBLT, Key

now for a break down


Code:
' Init tiles ddsd type and load the bitmap
    Call BMUtil.LoadByteData(FileName & "tiles" & GFX_EXT)


This loads the file as byte data ready for reading. GFX_EXT (modConstants i believe) will be changed later on.


Code:
Call BMUtil.DecryptByteData("47dn45")


This decrypts the data you jsut loaded, making sure the key in the " " matches the key for the file your loading (the key is set initially in the BMUtil.exe


Code:
Call BMUtil.DecompressByteData


Simple enough, thsi takes the decrypted data and decompresses it while its still in the memory.

Code:
With DDSD_Tile
        .lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
        .ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_VIDEOMEMORY
        .lWidth = BMUtil.ImageWidth
        .lHeight = BMUtil.ImageHeight
    End With


This gets the images height and width, and sets the surfaces height and width tot he same thing.

Code:
Set DD_TileSurf = DD.CreateSurface(DDSD_Tile)
    DC = DD_TileSurf.GetDC
    Call BMUtil.Blt(DC)
    Call DD_TileSurf.ReleaseDC(DC)


This makes DD_Tilesurf from DDSD_Tile, then it sets DC (our variable), to the DC of the the new surface.
After this it uses the dlls Blt command to put the tiles on the surface, then release the DC so it can be used.


Code:
DD_TileSurf.SetColorKey DDCKEY_SRCBLT, Key


this is the standard transparency key.


Now you need to go back and add this for sprites, items, and NPCs

Then run BMUtil.exe that you downlaoded in that package.

find yoru graphics files, and convert them tot he extension fo your choice. Make sure you remember the key you type in.

Go back tot he client, change all the "47dn45" to "thekeyyoutypedintotheprogramhere" and change GFX_EXT in modConstants tot he extesnion you chose.

There, your done
Reply
#2
Woah nice!

How hard is it for people to break into your graphics using this method?
Reply
#3
Verrigan Wrote:Just don't accidentally release your BMPs with the converted graphics files, and you should be fairly safe. Smile

*cough* mis *cough*
Reply
#4
Ha! it wasnt me!
Reply
#5
Maybe if you show part of the code(dont show your key Smile ) we can see whats wrong.
Reply
#6
You're blting it to the pictureboxes before the window is shown, so they will be cleared when the form is shown. You're gonna need to blt it when the form loads like before.

There still might be other problems with it, I dont remember exactly how it works. I havent looked at it in a while.
Reply
#7
when you load the forms. In the form_load code, or in the init code. Where it is originaly, only you put the new blt code instead of the old blt code.

If you are storing the arrows in a surface, you can load the file to the surface(only once where its normally done), then use surface.blttodc to blt to the picturebox's dc.
Reply
#8
grimsk8ter11 Wrote:Download this:
http://www.verrigan.net/bitmaputils/VWBitmapUtils.zip

Now open your client, go into the reference menu (Project->References)

And do what?
Reply
#9
zel you've been around forever, you should know this shit.

you add it as a reference. self explanatory instead of staring at the little check boxes =)
Reply
#10
I see it now, I was loading the group project file and it wouldn't compile. Tongue
Reply
#11
I get an invalid procedure call or argument error.

Code:
Set DD_SpriteSurf = DD.CreateSurface(DDSD_Sprite)

Here is my code in my init sub:

Code:
' Init sprite ddsd type and load the bitmap
    Call BMUtil.LoadByteData(FileName & "sprites" & GFX_EXT)
    Call BMUtil.DecryptByteData("47dn45")
    Call BMUtil.DecompressByteData
    With DDSD_Sprite
        .lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
        .ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_VIDEOMEMORY
        .lWidth = BMUtil.ImageWidth
        .lHeight = BMUtil.ImageHeight
    End With
    Set DD_SpriteSurf = DD.CreateSurface(DDSD_Sprite)
    DC = DD_SpriteSurf.GetDC
    Call BMUtil.Blt(DC)
    Call DD_SpriteSurf.ReleaseDC(DC)
    DD_SpriteSurf.SetColorKey DDCKEY_SRCBLT, Key
' Init tiles ddsd type and load the bitmap
    Call BMUtil.LoadByteData(FileName & "tiles" & GFX_EXT)
    Call BMUtil.DecryptByteData("47dn45")
    Call BMUtil.DecompressByteData
    With DDSD_Tile
        .lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
        .ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_VIDEOMEMORY
        .lWidth = BMUtil.ImageWidth
        .lHeight = BMUtil.ImageHeight
    End With
    Set DD_TileSurf = DD.CreateSurface(DDSD_Tile)
    DC = DD_TileSurf.GetDC
    Call BMUtil.Blt(DC)
    Call DD_TileSurf.ReleaseDC(DC)
    DD_TileSurf.SetColorKey DDCKEY_SRCBLT, Key
' Init item ddsd type and load the bitmap
    Call BMUtil.LoadByteData(FileName & "items" & GFX_EXT)
    Call BMUtil.DecryptByteData("47dn45")
    Call BMUtil.DecompressByteData
    With DDSD_Item
        .lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH
        .ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_VIDEOMEMORY
        .lWidth = BMUtil.ImageWidth
        .lHeight = BMUtil.ImageHeight
    End With
    Set DD_ItemSurf = DD.CreateSurface(DDSD_Item)
    DC = DD_ItemSurf.GetDC
    Call BMUtil.Blt(DC)
    Call DD_ItemSurf.ReleaseDC(DC)
    DD_ItemSurf.SetColorKey DDCKEY_SRCBLT, Key

I added the reference, and the file extension is correct (That wouldn't produce this error though anyway).
Reply
#12
When I hover the mouse over, they result as 0
Reply
#13
yep, definately correct, file extension is correct, i've registered and adding the dll to the references, the code is the exact code your pasted in the tutorial, i've set the variables, the files are in the right folders.
Reply
#14
I used that 128 value. It lets me log on but the tiles are all screwed up. And I get an error when entering the map editor. I assume that 128 was just a test value and that'll be why these things are happening?
Reply
#15
I load up that encryption software you included, I type ogf into the extension box, and 47dn45 into the password box. I don't bother with compression, it's not important for now I don't think. Then I load the .bmp files until they are all encrypted into .ogf files in the gfx folder. I've changed the GFX_EXT to .ogf in the constants module, and used the code I pasted above.

If you want you can download Oasis Source from http://www.os.nevetsweb.com and try it in the source for yourself, you might find it easier to work out the problem that way, i dunno.
Reply
#16
I want to use the compression, I just didn't think it was important while just testing. I've used the ZLib compression option before and still got the same error, i'll try the other one, see if it works.

[edit]
Ok I can log in with the NT Native compression, but I still get an invalid picture message on the map editor.
Reply
#17
I'll add this to a later version of Oasis Source then. It's not insanely important, but I guess it's a nice feature my users would like to have.
Reply
#18
I'll look here again after the weekend is over. I work late nights so don't get much time to do computer stuff over the weekend.
Reply
#19
Ok I got the map editor working, but I'll need you to help me fix the item editor and NPC editor (And anything else that loads the gfx into a picture/image box).

thanks.
Reply
#20
common gameboy, you can figure it out based on the map editor
Reply
#21
I tried using the source Verrigan posted in a similar manner but I still get an error. Unlike other people I actually attempt the problem at hand first before asking for code help.

I've stripped down the client to include no editors what-so-ever, so what I have now will work fine. I don't think the development kit needs this, as I would expect developers would need to look at the gfx files anyway.

So thanks for the help.
Reply
#22
Allright. Im attempting to add this... I have the same problem GameBoy was getting;

"Invalid Procedure Call or Arguement" On, Set DD_TileSurf = DD.CreateSurface(DDSD_Tile)

Ive set the GFX_EXT, and Im sure the password is correct. I used NT Native Compression. Although I hoverd over the imagehieght and imagewidth and there 0... I read were gameboy noted when he loaded the image as NT Native, it worked. Well, It's not for me... Any Help?
Reply
#23
Some times is a problem with dll/ocx registering.
Reply
#24
Dragoons Master Wrote:Some times is a problem with dll/ocx registering.

Eh, Took it out and learned how to use resource files for images, Yet I don't understand DirectX Enough to blt from a resource file. So I added this again, and it worked. But It laggs extremley. Any reason why it would?
Reply
#25
wisefire Wrote:
Dragoons Master Wrote:Some times is a problem with dll/ocx registering.

Eh, Took it out and learned how to use resource files for images, Yet I don't understand DirectX Enough to blt from a resource file. So I added this again, and it worked. But It laggs extremley. Any reason why it would?

Same here, I'm using seamless scrolling maps. Maybe that's an issue?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)