| Mirage Source http://miragesource.net/forums/ |
|
| .gif and .jpeg support http://miragesource.net/forums/viewtopic.php?f=210&t=1518 |
Page 1 of 2 |
| Author: | Robin [ Thu Mar 15, 2007 7:37 pm ] |
| Post subject: | .gif and .jpeg support |
Might support png as well, haven't tested. I followed JimCamels tutorial and thought it long winded and pointless. I looked around and found out how to load something as an image without using a picture box. It's mostly just common sense, but I found code all over for it. Code: Function CreateSurfaceFromFile(DirectDraw As DirectDraw7, ByVal _ FileName As String, SurfaceDesc As DDSURFACEDESC2) As _ DirectDrawSurface7 Dim Picture As StdPicture Dim width As Long Dim Height As Long Dim Surface As DirectDrawSurface7 Dim hdcPicture As Long Dim hdcSurface As Long Set Picture = LoadPicture(FileName) width = CLng((Picture.width * 0.001) * 567 / _ Screen.TwipsPerPixelX) Height = CLng((Picture.Height * 0.001) * 567 / _ Screen.TwipsPerPixelY) With SurfaceDesc If .lFlags = 0 Then .lFlags = DDSD_CAPS .lFlags = .lFlags Or DDSD_WIDTH Or DDSD_HEIGHT If .ddsCaps.lCaps = 0 Then _ .ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_VIDEOMEMORY If .lWidth = 0 Then .lWidth = width If .lHeight = 0 Then .lHeight = Height End With Set Surface = DirectDraw.CreateSurface(SurfaceDesc) hdcPicture = CreateCompatibleDC(0) SelectObject hdcPicture, Picture.Handle hdcSurface = Surface.GetDC StretchBlt hdcSurface, 0, 0, SurfaceDesc.lWidth, _ SurfaceDesc.lHeight, hdcPicture, 0, 0, _ width, Height, SRCCOPY Surface.ReleaseDC hdcSurface DeleteDC hdcPicture Set Picture = Nothing Set CreateSurfaceFromFile = Surface Set Surface = Nothing End Function Code: Public Declare Function CreateCompatibleDC Lib "gdi32" ( _
ByVal hdc As Long) As Long Public Declare Function SelectObject Lib "gdi32" ( _ ByVal hdc As Long, ByVal hObject As Long) As Long Public Declare Function StretchBlt Lib "gdi32" ( _ 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 dwRop As Long) As Long Public Declare Function DeleteDC Lib "gdi32" ( _ ByVal hdc As Long) As Long |
|
| Author: | Ramsey [ Thu Mar 15, 2007 8:16 pm ] |
| Post subject: | |
awesome, goin to test it later... |
|
| Author: | Xlithan [ Fri Mar 16, 2007 12:20 am ] |
| Post subject: | |
JimCamel, now there's a name that goes a long way back. |
|
| Author: | Verrigan [ Fri Mar 16, 2007 3:00 am ] |
| Post subject: | |
Just wanted to point out that the pictures are converted to bitmaps when the surface is created... No matter what format they are in. |
|
| Author: | Sephiroth187 [ Fri Mar 16, 2007 3:45 am ] |
| Post subject: | |
could always have Code: Dim pic as StdPicture
Set pic = loadpicture(app.path & "\Blabnla.jpg") Savepicture pic, app.path & "\tmp" Loadsurf app.path & "\tmp", pic 'Or what ever it is you do with loading a surface. I am also using pic because it has descriptions in it such as width/height. Not much data will be passed on through to the lordsurf sub AS pic does not contain the picture, only the handle number which is a reference to the spool. kill app.path & "\tmp" simplistic method. Might not be as good but....sure helps with minimal amount of lines Make sure you grab the width/height etc |
|
| Author: | Coke [ Fri Mar 16, 2007 11:08 am ] |
| Post subject: | |
Verrigan wrote: Just wanted to point out that the pictures are converted to bitmaps when the surface is created... No matter what format they are in.
If we are using .png files will it actually slow the client down at any point at all when it has to convert? |
|
| Author: | Sephiroth187 [ Fri Mar 16, 2007 12:10 pm ] |
| Post subject: | |
in order to load/convert PNG files you must use external DLL calling. VB does not support the PNG format. Look about on the net... I dont really like the png format idea. Just use ZLib with bmp for the win. |
|
| Author: | Robin [ Fri Mar 16, 2007 1:46 pm ] |
| Post subject: | |
I gave up trying to find a method for .png. gif is smaller anyway. faffing around with extrernal .dll files is pointless when there is a more optimised image file format. |
|
| Author: | Verrigan [ Fri Mar 16, 2007 1:58 pm ] |
| Post subject: | |
Fox wrote: Verrigan wrote: Just wanted to point out that the pictures are converted to bitmaps when the surface is created... No matter what format they are in. If we are using .png files will it actually slow the client down at any point at all when it has to convert? The conversion happens in memory, so since the file is smaller, it doesn't take as much time to load into memory, and then it's a matter of milliseconds for the conversion.. So.. I think using a smaller image format is better, which is why my bitmaputils class allows for compression (of any type). Taking all of that into account, you still need to remember that Windows 9x users have a lower limit on the maximum size of a bitmap (even in memory) than NT-based users.. (NT/2K/XP/2K3/Vista?) Sephiroth187 wrote: in order to load/convert PNG files you must use external DLL calling. VB does not support the PNG format. Look about on the net... I dont really like the png format idea. Just use ZLib with bmp for the win.
If I'm not mistaken, I believe the PNG format is actually open source. [edit] Yes, it is... Find it at http://www.libpng.org/pub/png/ One of these days, I need to change my bitmaputils to support PNGs.. Even though gifs are smaller, gif/jpg are both Lossy, and you (can) lose some information.. |
|
| Author: | Coke [ Fri Mar 16, 2007 5:51 pm ] |
| Post subject: | |
You guys that are going on about not being able to find .png format.. ^_^ its in the konfuze milestone source if you want it =P |
|
| Author: | Sephiroth187 [ Sat Mar 17, 2007 9:18 am ] |
| Post subject: | |
IMO png isnt worth it, bitmap format using zlib compression is way smaller than png. Although I like the idea of transparency capability, but again bitmap supports that to. Of course, it could provide to be easier But you could argue the process of changing PNG to BMP could be slower than just compress/uncompress. Especially on the scale size of the typical MS tileset. Such a pity, should break it up into smaller parts. IMO 128 x 128 |
|
| Author: | Robin [ Sat Mar 17, 2007 1:42 pm ] |
| Post subject: | |
Well, I use .gif files because all my maps are pre-made. I have the entire map blted, then the tops of houses etc. blted above everything else (aka. fringe). Means I'm not copying 900 different 32x32 blocks each loop. I then save the attributes to a 'map' file. Runs very nice. |
|
| Author: | Boo [ Fri Mar 23, 2007 9:48 pm ] |
| Post subject: | |
you should make an PNG support since its more compressed. JPG gets blurry and GIF tends to loose color :\ ----------- EDIT: They HAD an PNG support tutorial on Elysium somewhere but I think its gone, but just FYI, the dll needed for PNG is 'PaintX.dll' |
|
| Page 1 of 2 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|