//--------------------------------------------------------------------------- #include #pragma hdrstop #include "SvOp_Frm.h" #include "MainForm.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TSaveOptions_Frm *SaveOptions_Frm; //--------------------------------------------------------------------------- __fastcall TSaveOptions_Frm::TSaveOptions_Frm(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TSaveOptions_Frm::FormShow(TObject *Sender) { /* following statement needed to restore correct */ /* value if user changes options and presses ESC */ SaveOptions_Frm->ActiveControl = (TWinControl *)(RadioGroup_MetaHeader->Controls[MainFrm->FSaveOptions_MetaHeader]); RadioGroup_MetaHeader->ItemIndex = MainFrm->FSaveOptions_MetaHeader; RadioGroup_TransferSyntax->ItemIndex = MainFrm->FSaveOptions_TransferSyn; RadioGroup_VR->ItemIndex = MainFrm->FSaveOptions_VR; RadioGroup_GroupLengths->ItemIndex = MainFrm->FSaveOptions_GroupLengths; RadioGroup_LengthEncoding->ItemIndex = MainFrm->FSaveOptions_LengthEncoding; RadioGroup_ImageCompression->ItemIndex = MainFrm->FSaveOptions_ImageCompression; RadioGroup_ImagePhotometric->ItemIndex = MainFrm->FSaveOptions_ImagePhotometric; RadioGroup_ImageBPP->ItemIndex = MainFrm->FSaveOptions_ImageBPP; Edit_QFaqtor->Text = IntToStr(MainFrm->FSaveOptions_QFactor); } void __fastcall TSaveOptions_Frm::OKBtnClick(TObject *Sender) { MainFrm->FSaveOptions_MetaHeader = RadioGroup_MetaHeader->ItemIndex; MainFrm->FSaveOptions_TransferSyn = RadioGroup_TransferSyntax->ItemIndex; MainFrm->FSaveOptions_VR = RadioGroup_VR->ItemIndex; MainFrm->FSaveOptions_VR = RadioGroup_VR->ItemIndex; MainFrm->FSaveOptions_GroupLengths = RadioGroup_GroupLengths->ItemIndex; MainFrm->FSaveOptions_LengthEncoding = RadioGroup_LengthEncoding->ItemIndex; MainFrm->FSaveOptions_ImageCompression = RadioGroup_ImageCompression->ItemIndex; MainFrm->FSaveOptions_ImagePhotometric = RadioGroup_ImagePhotometric->ItemIndex; MainFrm->FSaveOptions_ImageBPP = RadioGroup_ImageBPP->ItemIndex; MainFrm->FSaveOptions_QFactor = StrToInt(Edit_QFaqtor->Text); } void __fastcall TSaveOptions_Frm::Edit_QFaqtorChange(TObject *Sender) { int nQF; try { nQF = StrToInt(Edit_QFaqtor->Text); if(nQF > 255 || nQF < 0) throw EConvertError("dummy"); FQFactor = Edit_QFaqtor->Text; } catch(EConvertError *e) { Edit_QFaqtor->Text = FQFactor; } } void __fastcall TSaveOptions_Frm::RadioGroup_ImageCompressionClick( TObject *Sender) { /* first, check for meta headers, VR and Transfer syntax */ if(RadioGroup_ImageCompression->ItemIndex == IMG_CMPR_NONE) { RadioGroup_MetaHeader->Controls[META_HEADER_ABSENT]->Enabled = true; RadioGroup_VR->Controls[VAL_REP_IMPLICIT]->Enabled = true; RadioGroup_TransferSyntax->Controls[TR_STX_BIG_ENDIAN]->Enabled = true; } else { if(RadioGroup_MetaHeader->ItemIndex == META_HEADER_ABSENT) RadioGroup_MetaHeader->ItemIndex = SAVE_OPT_DEFAULT; if(RadioGroup_VR->ItemIndex == VAL_REP_IMPLICIT) RadioGroup_VR->ItemIndex = SAVE_OPT_DEFAULT; if(RadioGroup_TransferSyntax->ItemIndex == TR_STX_BIG_ENDIAN) RadioGroup_TransferSyntax->ItemIndex = SAVE_OPT_DEFAULT; RadioGroup_MetaHeader->Controls[META_HEADER_ABSENT]->Enabled = false; RadioGroup_VR->Controls[VAL_REP_IMPLICIT]->Enabled = false; RadioGroup_TransferSyntax->Controls[TR_STX_BIG_ENDIAN]->Enabled = false; } /* then, check for image options */ VerifyImageOptions(); /* finally, check for Q-Factor */ Edit_QFaqtor->Enabled = (RadioGroup_ImageCompression->ItemIndex == IMG_CMPR_JPG_LSY); } void __fastcall TSaveOptions_Frm::VerifyImageOptions(void) { switch(RadioGroup_ImagePhotometric->ItemIndex) { case IMG_PHTMTR_RGB: RadioGroup_ImageBPP->ItemIndex = IMG_BPP_24; // only legal value for RGB break; case IMG_PHTMTR_PALET: if((RadioGroup_ImageCompression->ItemIndex == IMG_CMPR_JPG_LSY) || (RadioGroup_ImageCompression->ItemIndex == IMG_CMPR_JPG_LSLESS)) { RadioGroup_ImageCompression->ItemIndex = IMG_CMPR_NONE; // jpeg not allowed Application->MessageBox("JPEG cannot be used with photometric setting of PALETTE", "Error", MB_OK | MB_ICONERROR); } RadioGroup_ImageBPP->ItemIndex = IMG_BPP_8; // only legal value with palettes break; case IMG_PHTMTR_MONO: switch(RadioGroup_ImageCompression->ItemIndex) { case IMG_CMPR_NONE: case IMG_CMPR_RUN_LEN: if(RadioGroup_ImageBPP->ItemIndex == IMG_BPP_24) // only illegal value RadioGroup_ImageBPP->ItemIndex = IMG_BPP_8; break; case IMG_CMPR_JPG_LSLESS: RadioGroup_ImageBPP->ItemIndex = IMG_BPP_16; // only legal value break; case IMG_CMPR_JPG_LSY: RadioGroup_ImageBPP->ItemIndex = IMG_BPP_8; // only legal value break; } break; } } void __fastcall TSaveOptions_Frm::RadioGroup_ImagePhotometricClick( TObject *Sender) { VerifyImageOptions(); } void __fastcall TSaveOptions_Frm::RadioGroup_ImageBPPClick(TObject *Sender) { VerifyImageOptions(); }