KiS
03-15-2002, 11:17 AM
I've seen games made with vb and thir sprites have been in filetypes that are not ordinary bmp or jpg files. How can i do this to my pictures?
Putting my bmp file into binary ones?KiS 03-15-2002, 11:17 AM I've seen games made with vb and thir sprites have been in filetypes that are not ordinary bmp or jpg files. How can i do this to my pictures? denmeister 03-15-2002, 03:48 PM The easiest solution would be to download an OCX that will handle convertion of one image file type to another. Or maybe it was a custom format, which would not surpise me if it was a commercial application. But, the easiest method is to leave it as a BMP. Why go through all the trouble if you don't have to? Squirm 03-15-2002, 05:03 PM Many just use encrypted bmp/jpg/gif, to prevent people stealing. Sounds fair to me. :) AndreRyan 03-15-2002, 11:30 PM Or you could use Pixel by Pixel drawing functions written into an encrypted file. Pookie 03-16-2002, 12:12 AM Here is an example of encrypting a picturebox picture to give you an idea how to do it: Dim yLoop As Integer Dim xLoop As Integer Dim Colour As Long Dim EncriptKey As Long EncriptKey = 15784524 ' (change the number) Rnd -1 Randomize EncriptKey For yLoop = 0 To Picture1.ScaleHeight - 1 For xLoop = 0 To Picture1.ScaleWidth - 1 Colour = Picture1.Point(xLoop, yLoop) Colour = (Colour Xor Rnd * 16777215) Picture1.PSet (xLoop, yLoop), Colour Next Next This is a rather slow method of doing it, you can change the pset and point with the APIs getpixel and setpixel for some speed increase. You could also save the picture then rename the extension of the file to something like .mp3 so people won't even know it is a picture anymore then change it back in the program when needed. :) ChiefRedBull 03-16-2002, 02:31 AM The sprites you saw may have been ordinary file format, just renamed to discourage tampering... Did you try to open them in a graphics editor? KiS 03-16-2002, 03:59 AM Is there any place I can download a prog that will encrypt my picture files? If so, how do I open them in vb after they have been encrypted? ChiefRedBull 03-16-2002, 04:39 AM You can probably download several hundred encryption programs, but none that you will be able to use from within VB. You have to do your own encryption algorithm... which you then reverse when you load the pictures up again. KiS 03-16-2002, 12:33 PM Ho do I reverse the code that Lord Pookie posted? Squirm 03-16-2002, 12:43 PM Run it again on the encrypted picture. Being Xor means it will reverse itself. :) Quick test does reveal that it does indeed work KiS 03-16-2002, 01:07 PM I have tried to load a picture into a picture box and the picture got encrypted but it didnt get normal when I ran it again...... Squirm 03-16-2002, 02:50 PM This worked flawlessly for me: Option Explicit Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long Private Sub Command1_Click() Dim yLoop As Integer Dim xLoop As Integer Dim Colour As Long Dim EncriptKey As Long EncriptKey = 15784524 ' (change the number) Rnd -1 Randomize EncriptKey Picture1.Visible = False For yLoop = 0 To Picture1.ScaleHeight - 1 For xLoop = 0 To Picture1.ScaleWidth - 1 Colour = GetPixel(Picture1.hdc, xLoop, yLoop) Colour = Colour Xor 16777215 SetPixel Picture1.hdc, xLoop, yLoop, Colour Picture1.Refresh DoEvents Next Next Picture1.Visible = True End Sub What could you be doing wrong? :confused: Pookie 03-16-2002, 08:28 PM Make sure you use the same encryption number when decrypting it otherwise the picture will look very odd and snowy! :) |
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum