Mirage Source
http://www.miragesource.net/forums/

Verrigans Image System
http://www.miragesource.net/forums/viewtopic.php?f=210&t=42
Page 1 of 3

Author:  grimsk8ter11 [ Thu Jun 01, 2006 9:07 pm ]
Post subject:  Verrigans Image System

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

Author:  Verrigan [ Sun Jul 09, 2006 4:11 am ]
Post subject: 

Source has been provided for this... I believe the link is http://www.verrigan.net/bitmaputils/VWBitmapUtils.zip

Author:  Coke [ Thu Aug 24, 2006 5:03 pm ]
Post subject: 

Woah nice!

How hard is it for people to break into your graphics using this method?

Author:  Verrigan [ Thu Aug 24, 2006 5:19 pm ]
Post subject: 

It's easy if you give them your password... or store the password as plain text in your exe.. (public const imgpw = "this is the image file password")... But if you are slightly more careful, it would be a bit more difficult.. and if you have it randomly change the password, and reencrypt the data based on a random encryption method, you'd do even better to keep your graphics out of the hands of malicious users. :)

Just don't accidentally release your BMPs with the converted graphics files, and you should be fairly safe. :)

Author:  grimsk8ter11 [ Thu Aug 24, 2006 7:41 pm ]
Post subject: 

Verrigan wrote:
Just don't accidentally release your BMPs with the converted graphics files, and you should be fairly safe. :)


*cough* mis *cough*

Author:  Verrigan [ Thu Aug 24, 2006 8:39 pm ]
Post subject: 

I'm pretty sure that was me, actually..

Author:  Misunderstood [ Fri Aug 25, 2006 12:16 am ]
Post subject: 

Ha! it wasnt me!

Author:  NoviceScripter [ Sat Aug 26, 2006 10:19 pm ]
Post subject:  hi

hi, i followed the tutorial, and my arrow graphics display, and in my decryptgfx sub i have it bmu.blt t the right picboxes, but in the pic boxes there not there.. do i have to put something in the arrow editor and item editor and the other editor for that matter ? sorry if this seems nubbish, but i am a nub when it comes to blt lol.

thanks

Author:  Misunderstood [ Sat Aug 26, 2006 10:23 pm ]
Post subject: 

Maybe if you show part of the code(dont show your key :) ) we can see whats wrong.

Author:  NoviceScripter [ Sat Aug 26, 2006 10:28 pm ]
Post subject: 

[Sub DecryptGfx()
Dim BMU as BitmapUtils
Dim strFileName as String

'Initialize the BitmapUtils object.
Set BMU = New BitmapUtils

strFileName = App.Path & "/gfx/arrows.gfx"

'Load the bytes from the file into memory.
BMU.LoadByteData (strFileName)

'Decrypt the byte data.
BMU.DecryptByteData ("test")

'Decompress the byte data.
BMU.DecompressByteData

'Blt the image from memory to the Picture Box.
BMU.Blt (frmEditItem.picBow.hDC)
BMU.Blt (frmEditArrows.picArrows.hDC)
End Sub[/quote]

and in the item editor and arrow editor ini subs i didnt know what to do about the frm loadpicture line. so i deleted that. the background in the boxes currently is a lighter black color. :S

Author:  Misunderstood [ Sat Aug 26, 2006 10:51 pm ]
Post subject: 

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.

Author:  NoviceScripter [ Sat Aug 26, 2006 11:00 pm ]
Post subject: 

where would you suggest i put the blt at ?

Author:  Misunderstood [ Sat Aug 26, 2006 11:08 pm ]
Post subject: 

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.

Author:  Verrigan [ Fri Sep 01, 2006 6:22 pm ]
Post subject: 

Could someone please edit the first post in this thread, and replace the link with http://www.verrigan.net/bitmaputils/VWBitmapUtils.zip ? I'm getting errors of people looking for the file, and not getting it because I got rid of phpnuke. :P

Author:  Lea [ Fri Sep 01, 2006 8:48 pm ]
Post subject: 

Edited, enjoy.

Author:  James [ Wed Dec 20, 2006 9:40 pm ]
Post subject: 

Would this work if you've changed from BMP graphics to PNG graphics? Just wondering.

Author:  Verrigan [ Fri Dec 22, 2006 2:10 pm ]
Post subject: 

No - (BitmapUtils)

Author:  James [ Fri Dec 22, 2006 9:07 pm ]
Post subject: 

Okay, thanks anyways. =/

Author:  Xlithan [ Tue Mar 06, 2007 11:40 pm ]
Post subject:  Re: Verrigans Image System

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?

Author:  grimsk8ter11 [ Wed Mar 07, 2007 3:07 am ]
Post subject: 

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 =)

Author:  Xlithan [ Wed Mar 07, 2007 7:45 am ]
Post subject: 

I see it now, I was loading the group project file and it wouldn't compile. :P

Author:  Xlithan [ Wed Mar 07, 2007 8:45 am ]
Post subject: 

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).

Author:  Verrigan [ Thu Mar 08, 2007 7:08 pm ]
Post subject: 

What are the values of the ImageWidth and ImageHeight?

Author:  Xlithan [ Fri Mar 09, 2007 2:44 am ]
Post subject: 

When I hover the mouse over, they result as 0

Author:  Verrigan [ Fri Mar 09, 2007 6:39 am ]
Post subject: 

I believe that is what the problem is.. You're trying to create a surface with no height/width..

Check to make sure that the password you are using to decrypt your graphics files is correct.

Page 1 of 3 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/