Commit d0d17f39bf80150a6bbc5f57c4069a0c702b12c8
1 parent
b5bfce26
added ability to generate native pittpatt galleries
Showing
1 changed file
with
46 additions
and
0 deletions
openbr/plugins/pp5.cpp
| ... | ... | @@ -367,4 +367,50 @@ class PP5CompareDistance : public Distance |
| 367 | 367 | |
| 368 | 368 | BR_REGISTER(Distance, PP5CompareDistance) |
| 369 | 369 | |
| 370 | +/*! | |
| 371 | + * \ingroup galleries | |
| 372 | + * \brief For storing and comparing PittPatt templates natively | |
| 373 | + * \author Josh Klontz \cite jklontz | |
| 374 | + */ | |
| 375 | +class PP5Gallery : public Gallery | |
| 376 | + , public PP5Context | |
| 377 | +{ | |
| 378 | + Q_OBJECT | |
| 379 | + ppr_gallery_type gallery; | |
| 380 | + int face_id; | |
| 381 | + | |
| 382 | + ~PP5Gallery() | |
| 383 | + { | |
| 384 | + ppr_write_gallery(context, qPrintable(file.name), gallery); | |
| 385 | + ppr_free_gallery(gallery); | |
| 386 | + } | |
| 387 | + | |
| 388 | + void init() | |
| 389 | + { | |
| 390 | + face_id = 0; | |
| 391 | + ppr_create_gallery(context, &gallery); | |
| 392 | + } | |
| 393 | + | |
| 394 | + TemplateList readBlock(bool *done) | |
| 395 | + { | |
| 396 | + *done = true; | |
| 397 | + qFatal("PP5Gallery read not supported."); | |
| 398 | + return TemplateList(); | |
| 399 | + } | |
| 400 | + | |
| 401 | + void write(const Template &t) | |
| 402 | + { | |
| 403 | + if (!t.m().data) | |
| 404 | + return; | |
| 405 | + | |
| 406 | + ppr_face_type face; | |
| 407 | + createFace(t, &face); | |
| 408 | + TRY(ppr_add_face(context, &gallery, face, face_id, face_id)) | |
| 409 | + face_id++; | |
| 410 | + ppr_free_face(face); | |
| 411 | + } | |
| 412 | +}; | |
| 413 | + | |
| 414 | +BR_REGISTER(Gallery, PP5Gallery) | |
| 415 | + | |
| 370 | 416 | #include "plugins/pp5.moc" | ... | ... |