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

[EO 2.0] Load from PNG instead of BMP


barreytor
 Share

Recommended Posts

The atacched, and needed, files: http://www.mediafire.com/download.php?os377d5nyfes596

So, this is my very first post in this forum, and I would like to use it to share the very first thing I did just after downloading Eclipse Origins 2.3 Event system: Loading all the graphics from PNGs instead of BMPs.

It was kind of a quick, dirty job, and it doesn't allow you to use the alpha channel, but an overall 90% reduction in the actual filesize makes me think it's worth mentioning here.

(And basically it's the only thing I did until I found and downloaded EO 3.0 with DX8, but that's unrelated)

So, if you want to use the light PNG graphics format with your DirectDraw7 powered Eclipse Origins project, here are the steps:

**All client side**

First of all, download the attached zip and add all of the classes and modules to your client source.

Then, after adding everything, open the menu "Project->References", find "Ole automation" and activate it.

Second, find this:```
' load persistent surfaces
```in your modDirectDraw7 and change the extension from all files from ".bmp" to ".png"

Then, in modConstants, replace```
Public Const GFX_EXT As String = ".bmp"
```with```
Public Const GFX_EXT As String = ".png"
```

And now, for the real meat. Go back to modDirectDraw7 and, under```
Public NumFaces as Long
```add```
Private cImage As c32bppDIB
```

Next, go to the```
InitDDSurf
```sub, and replace

```
' set flags

SurfDesc.lFlags = DDSD_CAPS

SurfDesc.ddsCaps.lCaps = DDSD_Temp.ddsCaps.lCaps

' init object

Set Surf = DD.CreateSurfaceFromFile(fileName, SurfDesc)
```with```
' set flags

SurfDesc.lFlags = DDSD_CAPS Or DDSD_WIDTH Or DDSD_HEIGHT

SurfDesc.ddsCaps.lCaps = DDSD_Temp.ddsCaps.lCaps

' init object

' Set Surf = DD.CreateSurfaceFromFile(FileName, SurfDesc)

Set cImage = New c32bppDIB

cImage.LoadPicture_File (fileName)

SurfDesc.lWidth = cImage.Width

SurfDesc.lHeight = cImage.Height

Set Surf = DD.CreateSurface(SurfDesc)

Dim DC

DC = Surf.GetDC

cImage.Render (DC)

Surf.ReleaseDC (DC)

cImage.DestroyDIB
```

And that's that! Now you can load your image files from PNGs instead of BMPs… Only alpha channels won't do anything. (except for fully transparent pixels, for which, if I recall correctly, it DID work. Either that or the mask color system, which is still used)

For the task of mass changing the format, use something like PNGGauntlet or other.
Link to comment
Share on other sites

Damnit. Forgot about that. Editing this in a minute with that other absolutely neccesary step I somehow forgot.

EDIT: Okay, edited the original post with this simple step that's the cause of your problem there: "Then, after adding everything, open the menu "Project->References", find "Ole automation" and activate it."

You just have to open "Project->References" and activate OLE Automation.
Link to comment
Share on other sites

Works :D
But you need to use .png with an background if you let it Transparent it will change to black but…
Look self :D
At top an tileset without background
At bottom with

[![](http://www10.pic-upload.de/thumb/30.07.12/rap45v5om1y.png)](http://www.pic-upload.de/view-15370284/Unbenannt.png.html)

I can look funny if anyone want an black edge around all but yeah ;-)
Link to comment
Share on other sites

Well, that's the catch: You can't get any good use of the alpha channel as DirectDraw7 doesn't support it.
The method is more to get the bulk of the space used by the graphics cut down without losing any quality.
Make sure the tiles that are supposed to be transparent don't have any transparency gradient. That is: treat them as you would plain BMPs, only smaller filesize.
Link to comment
Share on other sites

@Dawntide:

> Does it increase the quality of the sprites, so i can make them larger without messing the quality up so hard?
> How you create transparent things, for example an icon, same way as with .bmp?

I think you're asking if zoomed sprites will look better. They won't look any better than they do in BMP, and nothing you can do to a sprite will make it have a better quality when zoomed in.
As for the transparent things question: Yes, do the same way as if it was a BMP.

In fact, when using this tutorial don't think of PNGs as PNGs, but as BMPs that use roughly a tenth of the  disk space.
Link to comment
Share on other sites

  • 3 weeks later...
Yes, do increase the strain on dynamically loading/unloading data.

Note to everyone; This does not and will not ever add proper PNG support. All it does is buffer it in memory and convert it to a bitmap when loaded, which is bloody inefficient when you're loading/unloading stuff on the fly. It works, but I honestly don't see the advantage to using it as the disk space used isn't all THAT big anyway.(Unless you're being a dunce and ship your game with graphics you're not even using).

While the effort is admirable, it's been done a few times and discussed more times. But it's really not worth bothering with.

Question though, did you look into seeing if it properly unloads everything it converts as well?

TL;DR, use it if you wish. But it's just a memory convertor. It uses more resources and time to load/unload stuff on the fly and will never add Alpha Masking.
Link to comment
Share on other sites

Well that sucks I started using this cause i didn't notice a performance drop but only tested with a few players.. the only reason i was using is my client size went from 450mb to 60 :/ guess I will remove it thanks for the info Joyce
Link to comment
Share on other sites

It shouldn't drop MUCH really. But it does slightly, not noticable on modern hardware though(Maybe on older computers with slower memory and such). I did make it sound more dramatic than it really is. :] Not sure how well it's designed in terms of memory management though, I haven't looked into it yet, so keep an eye out for memory leaks.
Link to comment
Share on other sites

Well you are adding 3 modules full of code.. not sure if its all used cause it looks to be ripped from something else but still may be wasteful.. I had been using ths on my lower end pc to map with no visible issues. I'll probably just remove it before i release the game.. if anyone else could maybe download the files and take a look any info would be helpful.
Link to comment
Share on other sites

> Note to everyone; This does not and will not ever add proper PNG support.

And that's why I switched to EO 3.0, though I did that after going ALL the way to find a way to find a way to be able to load PNG with EO 2.3\. Though it's a whole lot cleaner than the first try I went through (I saved a converted bitmap, then loaded THAT), it will indeed be a performance hit.

I just posted this here because I thought it be of some use for someone.

> Well you are adding 3 modules full of code.. not sure if its all used cause it looks to be ripped from something else but still may be wasteful.. I had been using ths on my lower end pc to map with no visible issues. I'll probably just remove it before i release the game.. if anyone else could maybe download the files and take a look any info would be helpful.

The modules are just the parsers that load and convert other image formats to PNG on memory. I didn't tamper with them, and they don't seem to have any malicious code, but as I said before, I just left this and went to EO 3.0 with it's DX8 and proper, native PNG support.
Link to comment
Share on other sites

  • 8 months later...
  • 1 month later...

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