Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
MyDialog Class Reference

#include <wxProfileDump.h>

+ Inheritance diagram for MyDialog:
+ Collaboration diagram for MyDialog:

Public Member Functions

 MyDialog (wxWindow *pParent, const wxString &title, wxString &profilePath)
 

Public Attributes

wxString m_profilePath
 

Detailed Description

Definition at line 188 of file wxProfileDump.h.

Constructor & Destructor Documentation

◆ MyDialog()

MyDialog::MyDialog ( wxWindow * pParent,
const wxString & title,
wxString & profilePath )

Definition at line 705 of file wxProfileDump.cpp.

705 :
706 wxDialog(pParent, wxID_ANY, title,wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
707{
708 wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
709 wxSizer *sizerRow = new wxBoxSizer(wxHORIZONTAL);
710
711 wxSize winSize = wxDefaultSize;
712
713 winSize.SetWidth(100);
714 wxStaticText *labelSttus = new wxStaticText(this, wxID_ANY, _T("Validation Status:"), wxDefaultPosition, winSize, wxALIGN_RIGHT);
715
716 winSize.SetWidth(500);
717 wxStaticText *textStatus = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, winSize,
718 wxSTATIC_BORDER | wxTE_LEFT | wxST_ELLIPSIZE_END);
719
720 sizerRow->Add(labelSttus, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5);
721 sizerRow->Add(textStatus, 1, wxALL | wxALIGN_CENTRE_VERTICAL, 5);
722
723 sizer->Add(sizerRow, wxSizerFlags().Expand());
724
725 winSize = wxSize(500, 400);
726 wxTextCtrl *textReport = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, winSize,
727 wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH | wxTE_BESTWRAP);
728
729 sizer->Add(textReport, wxSizerFlags(1).Expand());
730
731 icValidateStatus nStat;
732 wxString theReport, theValidateStatus;
733
734 std::string ver_str;
735
736 if (profilePath.IsEmpty()) {
737 theReport = "Invalid Profile Path!\n";
738 nStat = (icValidateStatus)-1;
739 }
740 else {
741 std::string sReport;
742 wxBeginBusyCursor();
743 char * pPath = strdup( profilePath.mb_str() );
744 CIccProfile *pIcc = ValidateIccProfile(pPath, sReport, nStat);
745 if (pIcc) {
746 int m, n;
747 TagEntryList::iterator i, j;
748 CIccInfo Fmt;
749 char str[256];
750
751 icHeader* pHdr = &pIcc->m_Header;
752 ver_str = " for version ";
753 ver_str += Fmt.GetVersionName(pHdr->version);
754
755 // Report all duplicated tags in the tag index
756 // Both ICC.1 and ICC.2 are silent on what should happen for this but report as a warning!!!
757 for (n = 0, i = pIcc->m_Tags->begin(); i != pIcc->m_Tags->end(); i++, n++)
758 for (m = 0, j = pIcc->m_Tags->begin(); j != pIcc->m_Tags->end(); j++, m++)
759 if ((i != j) && (i->TagInfo.sig == j->TagInfo.sig)) {
760 sprintf(str, "%28s is duplicated at positions %d and %d!\n", Fmt.GetTagSigName(i->TagInfo.sig), n, m);
761 sReport += str;
762 nStat = icMaxStatus(nStat, icValidateWarning);
763 }
764
765 // Check additional details if doing detailed validation:
766 // - First tag data offset is immediately after the Tag Table
767 // - Tag data offsets are all 4-byte aligned
768 // - Tag data should be tightly abutted with adjacent tags (or the end of the Tag Table)
769 // (note that tag data can be reused by multiple tags and tags do NOT have to be order)
770 // - Last tag also has to be padded and thus file size is always a multiple of 4. See clause
771 // 7.2.1, bullet (c) of ICC.1:2010 and ICC.2:2019 specs.
772 // - Tag offset + Tag Size should never go beyond EOF
773 // - Multiple tags can reuse data and this is NOT reported as it is perfectly valid and
774 // occurs in real-world ICC profiles
775 // - Tags with overlapping tag data are considered highly suspect (but officially valid)
776 // - 1-3 padding bytes after each tag's data need to be all zero *** NOT DONE - TODO ***
777 int closest, pad, rndup, smallest_offset = pHdr->size;
778
779 // File size is required to be a multiple of 4 bytes according to clause 7.2.1 bullet (c):
780 // "all tagged element data, including the last, shall be padded by no more than three
781 // following pad bytes to reach a 4 - byte boundary"
782 if ((pHdr->version >= icVersionNumberV4_2) && (pHdr->size % 4 != 0)) {
783 sReport += icMsgValidateNonCompliant;
784 sReport += "File size is not a multiple of 4 bytes (last tag needs padding?).\n";
785 nStat = icMaxStatus(nStat, icValidateNonCompliant);
786 }
787
788 for (i = pIcc->m_Tags->begin(); i != pIcc->m_Tags->end(); i++) {
789 rndup = 4 * ((i->TagInfo.size + 3) / 4); // Round up to a 4-byte aligned size as per ICC spec
790 pad = rndup - i->TagInfo.size; // Optimal smallest number of bytes of padding for this tag (0-3)
791
792 // Is the Tag offset + Tag Size beyond EOF?
793 if (i->TagInfo.offset + i->TagInfo.size > pHdr->size) {
794 sReport += icMsgValidateNonCompliant;
795 sprintf(str, "Tag %s (offset %d, size %d) ends beyond EOF.\n",
796 Fmt.GetTagSigName(i->TagInfo.sig), i->TagInfo.offset, i->TagInfo.size);
797 sReport += str;
798 nStat = icMaxStatus(nStat, icValidateNonCompliant);
799 }
800
801 // Is it the first tag data in the file?
802 if ((int)i->TagInfo.offset < smallest_offset) {
803 smallest_offset = (int)i->TagInfo.offset;
804 }
805
806 // Find closest tag after this tag, by scanning all other tag offsets
807 closest = pHdr->size;
808 for (j = pIcc->m_Tags->begin(); j != pIcc->m_Tags->end(); j++) {
809 if ((i != j) && (j->TagInfo.offset > i->TagInfo.offset) && ((int)j->TagInfo.offset <= closest)) {
810 closest = j->TagInfo.offset;
811 }
812 }
813
814 // Check if closest tag after this tag is less than offset+size - in which case it overlaps! Ignore last tag.
815 if ((closest < (int)i->TagInfo.offset + (int)i->TagInfo.size) && (closest < (int)pHdr->size)) {
816 sReport += icMsgValidateWarning;
817 sprintf(str, "Tag %s (offset %d, size %d) overlaps with following tag data starting at offset %d.\n",
818 Fmt.GetTagSigName(i->TagInfo.sig), i->TagInfo.offset, i->TagInfo.size, closest);
819 sReport += str;
820 nStat = icMaxStatus(nStat, icValidateWarning);
821 }
822
823 // Check for gaps between tag data (accounting for 4-byte alignment)
824 if (closest > (int)i->TagInfo.offset + rndup) {
825 sReport += icMsgValidateWarning;
826 sprintf(str, "Tag %s (size %d) is followed by %d unnecessary additional bytes (from offset %d).\n",
827 Fmt.GetTagSigName(i->TagInfo.sig), i->TagInfo.size, closest - (i->TagInfo.offset + rndup), (i->TagInfo.offset + rndup));
828 sReport += str;
829 nStat = icMaxStatus(nStat, icValidateWarning);
830 }
831 }
832
833 // Clause 7.2.1, bullet (b): "the first set of tagged element data shall immediately follow the tag table"
834 // 1st tag offset should be = Header (128) + Tag Count (4) + Tag Table (n*12)
835 if ((n > 0) && (smallest_offset > 128 + 4 + (n * 12))) {
836 sReport += icMsgValidateNonCompliant;
837 sprintf(str, "First tag data is at offset %d rather than immediately after tag table (offset %d).\n",
838 smallest_offset, 128 + 4 + (n * 12));
839 sReport += str;
840 nStat = icMaxStatus(nStat, icValidateNonCompliant);
841 }
842 delete pIcc;
843 }
844 wxEndBusyCursor();
845
846 if (sReport.empty())
847 sReport = "There is nothing to report.\n";
848
849 theReport = sReport.c_str();
850 }
851
852 wxColour status_color = *wxBLACK;
853 switch(nStat) {
854 case icValidateOK:
855 status_color = wxColour("DARK GREEN");
856 ver_str = "Valid Profile" + ver_str;
857 break;
858
860 status_color = wxColour("ORANGE RED");
861 ver_str = "Validation Warning(s)" + ver_str;
862 break;
863
865 status_color = *wxRED;
866 ver_str = "Profile violates ICC Specification" + ver_str;
867 break;
868
870 status_color = *wxRED;
871 ver_str = "Critical Error - Profile Violates ICC Specification" + ver_str;
872 break;
873
874 default:
875 status_color = *wxRED;
876 ver_str = "Unknown Validation Status";
877 break;
878 }
879 theValidateStatus = ver_str.c_str();
880
881 textStatus->SetForegroundColour(status_color);
882 textStatus->SetLabel(theValidateStatus);
883 *textReport << theReport;
884
885 SetSizer(sizer);
886 sizer->Fit(this);
887}
icValidateStatus
Definition IccDefs.h:118
@ icValidateOK
Definition IccDefs.h:119
@ icValidateWarning
Definition IccDefs.h:120
@ icValidateCriticalError
Definition IccDefs.h:122
@ icValidateNonCompliant
Definition IccDefs.h:121
CIccProfile * ValidateIccProfile(CIccIO *pIO, std::string &sReport, icValidateStatus &nStatus)
Name: ValidateIccProfile.
icValidateStatus icMaxStatus(icValidateStatus s1, icValidateStatus s2)
Name: icMaxStatus.
Definition IccUtil.cpp:244
const char * icMsgValidateWarning
Definition IccUtil.cpp:90
const char * icMsgValidateNonCompliant
Definition IccUtil.cpp:91
Type: Class.
Definition IccUtil.h:303
const icChar * GetVersionName(icUInt32Number val)
Definition IccUtil.cpp:1428
const icChar * GetTagSigName(icTagSignature sig)
Definition IccUtil.cpp:1495
#define icVersionNumberV4_2
The Profile header.
icUInt32Number version
icUInt32Number size

References CIccInfo::GetTagSigName(), CIccInfo::GetVersionName(), icMaxStatus(), icMsgValidateNonCompliant, icMsgValidateWarning, icValidateCriticalError, icValidateNonCompliant, icValidateOK, icValidateWarning, icVersionNumberV4_2, icHeader::size, ValidateIccProfile(), and icHeader::version.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_profilePath

wxString MyDialog::m_profilePath

Definition at line 193 of file wxProfileDump.h.


The documentation for this class was generated from the following files: