Jump to content
  • Advertisement
Dave Haylett

C# WriteableBitmaps - Encoding and Decoding TIFF in memory only

Recommended Posts

I'm using WriteableBitmaps in my project, and the tiffbitmapencoder and tiffbitmapdecoder classes to save off and restore a certain large graphic file from a WriteableBitmap to hard disc (the image is too big for the PNGbitmapencoder/decoder).

This is working ok, but I'd like to encode to and decode from memory if possible, instead of having to save to disc. This is because, as part of the user experience this massive image can get wiped/cut down, and it takes a few precious seconds to reconstruct it again from scratch (which is also part of the user experience), but I can't afford the memory to just clone the whole image into another bitmap and clone it back again when needed, instead of rebuilding.

Compressing it to TIF and holding in memory until it's needed again seems a viable option, but currently I can only compress/decompress to/from a file on disc.

I've tried using MemoryStream instead of FileStream, and even though the encoder seems to like it, the decoder doesn't.

Is it possible for me to achieve this?

Share this post


Link to post
Share on other sites
Advertisement
On 20.1.2018 at 1:15 PM, Dave Haylett said:

I've tried using MemoryStream instead of FileStream, and even though the encoder seems to like it, the decoder doesn't.

What was the error you achieved here?

Normally any .Net class that takes a stream is compatible with any stream so there should be no difference with MemoryStream against FileStream. You might have provided too few data for your in memory image or too few space

Share this post


Link to post
Share on other sites

Hi Shaarigan. Thanks for your reply but I've decided to work around my issue by silently rebuilding the image in the background. The user only initially sees part of the image so I can kind of get away with 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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!