Jump to content

Working with Layers in Save Function


Katai

Recommended Posts

I'm brand new to working with plugins on Paint.net. I'm trying to speed up my workflow a bit. I do sprite animations within Paint.net, and I'm trying to find a way that will help me get to my final format a bit quicker.

Basically, I have each layer as a frame of the animation. What I want to do is take each layer and stack them side by side so it becomes a proper sprite sheet. At the same time, I want to write an XML file with some data about the spritesheet. Ideally, I want to do this when I save.

I've been playing around with the FileTypes template, but I honestly have no idea where to start. I initially thought I could iterate through the layers from the "input" Document object and draw them onto a surface with an offset, but I honestly have no idea what any of the functions within the Layer class does.

Link to comment
Share on other sites

Hi Katai, welcome to the forum.

Have you seen these?

Animation Helper v0.81

and

SpriteSheet Animation v1.3

They appear to be close to what you're looking for. It's not as much fun as coding your own, but it is a lot less work!

Link to comment
Share on other sites

At the same time, I want to write an XML file
You can't save to 2 files. You're given a Stream to save to, and no information about the file name or location. FileTypes are not export plugins.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Yes, I have seen those, and neither of them really do what I need them to do. They both animate existing sprite sheets, but doesn't help me at all in creating one. The tedious part is aligning each frame and recording the coordinate data in an XML file that can be read by my game engine.

Link to comment
Share on other sites

Yes, I have seen those, and neither of them really do what I need them to do. They both animate existing sprite sheets, but doesn't help me at all in creating one. The tedious part is aligning each frame and recording the coordinate data in an XML file that can be read by my game engine.

You may write one XML file and embed the pixel data. This way it would also be possible to load the file.

At the end this means you would define your own filetype.

But to use agif or apng filetype may be easier...

midoras signature.gif

Link to comment
Share on other sites

  • 2 months later...

Sorry for bringing this back from the grave. I thought I found a different viable solution to my problem, but now I'm coming back around to this.

So here is what I want to do in detail:

  • Create a series of animation frames in paint.net, 1 frame per layer
  • Save the frames as a single PNG file to create the "sprite sheet"
    • The save function will take each layer and set them side by side onto a single layer.

    [*]Write metadata (custom exif?) that contains information about each frame (coordinates and size)

    [*]Write metadata that contains animation sequences

Are these things feasible within a Paint.net filetype plugin?

Link to comment
Share on other sites

If you're writing this for your own use you can do whatever you'd like, but you cannot override the built-in PNG handler. *.PNG files will never get routed to a plugin. (This is by design.)

You can save out to additional files by using the stuff in System.Drawing, e.g. Bitmap.Save(ImageFormat.Png).

The bitmaps in Paint.NET's Document class are stored within the layers. Cast the Layer to BitmapLayer, and grab the Surface property (which is of type PaintDotNet.Surface). Next, use CreateAliasedGdipBitmap() to create a Bitmap instance that refers to the same memory, and which can then be used with Bitmap's Save method. Don't forget to call Dispose() on the Bitmap immediately once you're done with it.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

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.

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