! * \brief regTestWritePixAndCheck() * * \param[in] rp regtest parameters * \param[in] pix to be written * \param[in] format of output pix * \return 0 if OK, 1 on error a failure in comparison is not an error * * * Notes: * (1) This function makes it easy to write the pix in a numbered * sequence of files, and either to: * (a) wr
| 701 | * </pre> |
| 702 | */ |
| 703 | l_int32 |
| 704 | regTestWritePixAndCheck(L_REGPARAMS *rp, |
| 705 | PIX *pix, |
| 706 | l_int32 format) |
| 707 | { |
| 708 | char namebuf[256]; |
| 709 | |
| 710 | PROCNAME("regTestWritePixAndCheck"); |
| 711 | |
| 712 | if (!rp) |
| 713 | return ERROR_INT("rp not defined", procName, 1); |
| 714 | if (!pix) { |
| 715 | rp->success = FALSE; |
| 716 | return ERROR_INT("pix not defined", procName, 1); |
| 717 | } |
| 718 | if (format < 0 || format >= NumImageFileFormatExtensions) { |
| 719 | rp->success = FALSE; |
| 720 | return ERROR_INT("invalid format", procName, 1); |
| 721 | } |
| 722 | |
| 723 | /* Generate the local file name */ |
| 724 | snprintf(namebuf, sizeof(namebuf), "/tmp/lept/regout/%s.%02d.%s", |
| 725 | rp->testname, rp->index + 1, ImageFileFormatExtensions[format]); |
| 726 | |
| 727 | /* Write the local file */ |
| 728 | if (pixGetDepth(pix) < 8) |
| 729 | pixSetPadBits(pix, 0); |
| 730 | pixWrite(namebuf, pix, format); |
| 731 | |
| 732 | /* Either write the golden file ("generate") or check the |
| 733 | local file against an existing golden file ("compare") */ |
| 734 | regTestCheckFile(rp, namebuf); |
| 735 | |
| 736 | return 0; |
| 737 | } |
| 738 | |
| 739 | |
| 740 | /*! |
nothing calls this directly
no test coverage detected