Jump to content

Loading multiple images from a single file

Recommended Posts

The tl;dr is that I wish to view the mips of an image, and if each mip was loaded as a separate image or layer, this would be fine.


The native DDS support is great, but doesn't seem to allow viewing of mips (in fact, nothing I can find does). I'm writing my own texture format reader/writer (for reasons not pertinent to this thread), and it seems that there is a 1:1 correlation between files and images, and no way to create layers in the OnLoad() delegate.

What I could do is create a bigger single image that shows all mips.  However, this would not be savable.


Is there a way to create multiple images or layers from a single OnLoad() call?




Link to comment
Share on other sites

You can not return more than one doc (image) from OnLoad. But the doc may contain multiple layers in the size of the documunt.

So you have split the input stream into multiple bitmaps and add these bitmaps as layers.

bitmap = new Bitmap(ms);
Surface surface = Surface.CopyFromBitmap(bitmap, false);
BitmapLayer bitmapLayer = new BitmapLayer(surface);
bitmapLayer.Name = "Layer N";
bitmapLayer.Visible = true;
bitmapLayer.SetBlendOp(new UserBlendOps.NormalBlendOp());
bitmapLayer.Opacity = 255;

midoras signature.gif

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...