Skip to content

[Feature] Export selected sprite(s) to png or jpg #78

@foxnne

Description

@foxnne

The goal would be to add a new hotkey, as well as a new in-app DVUI modal dialog to choose options for the export. To see what existed before, check out the mach branch (builds with latest mach nominated version of zig) and select sprites and press ctrl/cmd + p.

For now, since animations are not currently in pixi, this dialog should just offer options to export the selected sprites either as a single image (combined) or as individual images per sprite. It should also offer the ability to choose an export scale, as exporting for posting online would mean we would need to offer something like 1-32x scale in a slider for the export. Maybe we cap the max export size at a reasonable size? 4092x4092 or something?

I tried to think through the steps I would take to implement this new feature, hopefully this is helpful:

  • Add a new keybind, which would be ctrl/cmd + p and added here.
  • Process the new keybind from FileWidget, here and call function below.
  • Add a new function, I suppose print to Editor, which is kind of a mess of functions right now, but general functions that operate on the active file tend to end up there. Maybe here?
  • Check out copy in Editor, it grabs each sprite, and copies them into the "transform" layer, which is just essentially writing them into a blank texture/dvui image source, and then crops them down to just the non-transparent pixels. For exporting them with the hotkey, we would essentially just skip the cropping.
  • Then we need to offer a dialog to choose the export type and location. As of the latest DVUI, we can now offer exporting png and jpg, so I'd love to support both. This would mean creating a new dialog box gui in pixi, which then opens a native file dialog through DVUI.
  • If possible, the dialog box would let you choose file type through a dropdown, and also export scale, since we would like to export pixel art at sometimes up to 16-32x scale for posting or whatever

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions