Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: template file format documentation #45

Open
sjlongland opened this issue May 17, 2024 · 3 comments
Open

Query: template file format documentation #45

sjlongland opened this issue May 17, 2024 · 3 comments

Comments

@sjlongland
Copy link

Hi,

A silly question, is there some documentation on how the template files are constructed?
I have a number of stock images and I'd like to mass-create different templates based on those stock images.

I already have a netpbm-based pipeline orchestrated with make that can take those stock images, pad or crop images to 4:3 aspect ratio, scale to 320×240px, add a 16px header and apply a call-sign watermark.

There are two call-signs I use: my normal one VK4MSL, but 3 days a year, ACMA's class license permits us to substitute VK with AX, and so I've got watermarks and headers with AX4MSL.

The challenge is creating the templates is a manual process. At best I can open up a template based on one of the VK-watermarked stock images, delete the background image, insert an AX-watermarked image, send it to the back, expand it, then save the resulting template as a new file. This is tedious.

Pixel-positions of text fields in the template do not change between the VK and AX variants. Assuming the positioning and font selection information of each text field and replay field is known, how would one go about constructing a template file?

@hspil
Copy link
Collaborator

hspil commented May 20, 2024

Based on a cursory glance at what I think is the relevant code, I get the impression is that it is .png, just like "Save as Image" just with a different file extension.
I'm reading editor.cpp and it seems like very similar code is being used for editor::slotFileSaveImage() and editor::slotFileSaveTemplate()

@sjlongland
Copy link
Author

Yep, it could be a PNG extension that describes the template… but it's not just a PNG. PNGs from what I understand don't natively implement templating.

Likely there's some custom "chunk" format used to describe the different elements of the template that's embedded in the PNG. Macromedia Fireworks used to do something similar to implement layers, but this was an extension of, rather than a built-in feature of, the PNG format.

@dl8dtl
Copy link
Collaborator

dl8dtl commented May 23, 2024

Actual saving happens in editorScene::save. Based on the templ parameter, it eventually dispatches to:

  if(!f.open(QIODevice::WriteOnly)) return false;
  QDataStream str(&f);
  str.setVersion(QDataStream::Qt_4_4);
  // Header with a "magic number" and a version
  str << (quint32) MAGICNUMBER;
  str <<  CONFIGVERSION;
  str << (quint16) QDataStream::Qt_4_4;
  graphItemBase *it;
  foreach(QGraphicsItem *t,items())
    {
      it=qgraphicsitem_cast<graphItemBase *>(t);
      if(t->type()>graphItemBase::BASE)
        {
          it->save(str);
        }
    }
  f.close();

So the actual code to write things out is in graphItemBase::save.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants