Sign in to follow this  
PumpkinPieman

Image Compression Libs in C#?

Recommended Posts

PumpkinPieman    382
Hey, I'm looking for an image compression library that is done in C#. I posted this over at the XNA board, but I had no luck there. What I'm trying to find is some kind of library that will allow me to bypass the content pipeline and compress images. For the application I'm using I need to write textures, which is something that doesn't seem like its supported on the XBOX unless I do it this way. I figured the people over at GD might know of a few libraries that can aid me. (no real preference at this point. I wish there was a libpng for C#)

Share this post


Link to post
Share on other sites
PumpkinPieman    382
That's usually the first thing that is mentioned. I can use this on the PC version, but "apparently" those two methods don't exist on the xbox versions. So I was kind of looking for something outside of the standard API and XNA. Other people suggested I write my own compression library, as if I have nothing better to do or something. Hah.

Share this post


Link to post
Share on other sites
MJP    19786
So what you need is to be able to save textures on an Xbox storage unit, and saved them in a compressed format?

If that's the case, I don't know of any purely-managed implementations of PNG or JPEG or anything like that.

Share this post


Link to post
Share on other sites
Codeka    1239
Quote:
Original post by PumpkinPieman
That's usually the first thing that is mentioned. I can use this on the PC version, but "apparently" those two methods don't exist on the xbox versions. So I was kind of looking for something outside of the standard API and XNA. Other people suggested I write my own compression library, as if I have nothing better to do or something. Hah.


Oh, you're right. I didn't notice that!

As far as I know, there's no 100% managed implementation of the png library. I assume nobody's written one before because it comes built into the System.Drawing namespace (but of course, that's also not available in XNA).

You should be able to write a .bmp library pretty easily, the .bmp format is quite simple [smile]

Share this post


Link to post
Share on other sites
Flimflam    665
Quote:
Original post by Codeka
Both Texture2D.FromFile and Texture.Save (which Texture2D inherits) support PNG format. In fact, they support all formats listed here.


Just a little nitpick on this, even though it's note quite relevant to what the original poster is asking; Texture.Save cannot save in .ppm or .tga. Shame, cause when I originally researched this, .tga was exactly what I was looking at.

Share this post


Link to post
Share on other sites
Codeka    1239
Quote:
Original post by PumpkinPieman
That's one of the issues. I'd work with the BMP format, but I'm trying to compress mighty big textures. 8000x8000 at max.


Can you even generate an 8000x8000 image on an XBOX? By my calculations, that would require 244MB of memory and the XBOX only has 512MB of memory which is shared between the CPU and GPU. It's going to be a bit of a tight squeeze when you've got the .NET CF running, the XBOX OS itself and your game.

In any case, does it need to be an image file that you save? Could you save a .bmp and then use SharpZipLib to create a .zip file? I mean, there's not much point viewing an 8000x8000 image on your TV so you could save the "raw" 8000x8000 in a zip and a "preview" at a lower resolution for actually viewing by the XBOX (if that's the point anyway).

Also, SharpZipLib could be a starting point for implementing managed .png compression, since the algorithm .png uses is supported by SharpZipLib.

Share this post


Link to post
Share on other sites
PumpkinPieman    382
Quote:
Original post by Codeka
Quote:
Original post by PumpkinPieman
That's one of the issues. I'd work with the BMP format, but I'm trying to compress mighty big textures. 8000x8000 at max.


Can you even generate an 8000x8000 image on an XBOX? By my calculations, that would require 244MB of memory and the XBOX only has 512MB of memory which is shared between the CPU and GPU. It's going to be a bit of a tight squeeze when you've got the .NET CF running, the XBOX OS itself and your game.

In any case, does it need to be an image file that you save? Could you save a .bmp and then use SharpZipLib to create a .zip file? I mean, there's not much point viewing an 8000x8000 image on your TV so you could save the "raw" 8000x8000 in a zip and a "preview" at a lower resolution for actually viewing by the XBOX (if that's the point anyway).

Also, SharpZipLib could be a starting point for implementing managed .png compression, since the algorithm .png uses is supported by SharpZipLib.


Yeah, it cannot support textures of that size. However the terrain I'm generating doesn't use the whole texture. It's broken up in to 128x128 segments, and a static vertex buffer for shader height \ splatter manipulations. This is why if I get straight data from from the library, I don't have to worry about the texture2d throwing an exception for exceeding the limit.

Yeah, I've seen Sharp zLib. I've just tested the SevenZip lib for C#, and it was quite slow. I'm going to give this a shot and see what comes out of it.

Share this post


Link to post
Share on other sites

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

Sign in to follow this