├── BitFrm.cpp ├── BitFrm.dfm ├── BitFrm.h ├── COPYING ├── ExportFrm.cpp ├── ExportFrm.dfm ├── ExportFrm.h ├── HexFrm.cpp ├── HexFrm.dfm ├── HexFrm.h ├── HistogramFrm.cpp ├── HistogramFrm.dfm ├── HistogramFrm.h ├── ImageFrm.cpp ├── ImageFrm.dfm ├── ImageFrm.h ├── LogFrm.cpp ├── LogFrm.dfm ├── LogFrm.h ├── README.md ├── ROMBitSettingsFrm.cpp ├── ROMBitSettingsFrm.dfm ├── ROMBitSettingsFrm.h ├── SelPatFrm.cpp ├── SelPatFrm.dfm ├── SelPatFrm.h ├── binary.ico ├── bitract.bpr ├── bitract.cpp ├── bitract.ini └── bitract.res /BitFrm.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #pragma hdrstop 5 | 6 | #include "BitFrm.h" 7 | //--------------------------------------------------------------------------- 8 | #pragma package(smart_init) 9 | #pragma link "ievect" 10 | #pragma link "ieview" 11 | #pragma link "imageenview" 12 | #pragma link "histogrambox" 13 | #pragma link "imageenproc" 14 | #pragma resource "*.dfm" 15 | TBitForm *BitForm; 16 | //--------------------------------------------------------------------------- 17 | __fastcall TBitForm::TBitForm(TComponent* Owner) 18 | : TForm(Owner) 19 | { 20 | } 21 | //--------------------------------------------------------------------------- 22 | -------------------------------------------------------------------------------- /BitFrm.dfm: -------------------------------------------------------------------------------- 1 | object BitForm: TBitForm 2 | Left = 233 3 | Top = 107 4 | Width = 264 5 | Height = 269 6 | Caption = 'BitForm' 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'MS Sans Serif' 12 | Font.Style = [] 13 | OldCreateOrder = False 14 | Visible = True 15 | DesignSize = ( 16 | 240 17 | 242) 18 | PixelsPerInch = 96 19 | TextHeight = 13 20 | object BitView: TImageEnVect 21 | Left = 0 22 | Top = 0 23 | Width = 240 24 | Height = 81 25 | ParentCtl3D = False 26 | LegacyBitmap = False 27 | ImageEnVersion = '3.0.2' 28 | Anchors = [akLeft, akTop, akRight] 29 | EnableInteractionHints = True 30 | TabOrder = 0 31 | end 32 | object HistogramBox: THistogramBox 33 | Left = 0 34 | Top = 81 35 | Width = 240 36 | Height = 162 37 | AttachedImageEnProc = BitProc 38 | HistogramKind = [hkBlue] 39 | Align = alBottom 40 | end 41 | object BitProc: TImageEnProc 42 | AttachedImageEn = BitView 43 | Background = clBtnFace 44 | PreviewsParams = [prppShowResetButton, prppHardReset] 45 | PreviewFont.Charset = DEFAULT_CHARSET 46 | PreviewFont.Color = clWindowText 47 | PreviewFont.Height = -11 48 | PreviewFont.Name = 'MS Sans Serif' 49 | PreviewFont.Style = [] 50 | Left = 8 51 | Top = 8 52 | end 53 | end 54 | -------------------------------------------------------------------------------- /BitFrm.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef BitFrmH 4 | #define BitFrmH 5 | //--------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "ievect.hpp" 11 | #include "ieview.hpp" 12 | #include "imageenview.hpp" 13 | #include "histogrambox.hpp" 14 | #include "imageenproc.hpp" 15 | //--------------------------------------------------------------------------- 16 | class TBitForm : public TForm 17 | { 18 | __published: // IDE-managed Components 19 | TImageEnVect *BitView; 20 | THistogramBox *HistogramBox; 21 | TImageEnProc *BitProc; 22 | private: // User declarations 23 | public: // User declarations 24 | __fastcall TBitForm(TComponent* Owner); 25 | }; 26 | //--------------------------------------------------------------------------- 27 | extern PACKAGE TBitForm *BitForm; 28 | //--------------------------------------------------------------------------- 29 | #endif 30 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019, Chris Gerlinsky 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 17 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | 24 | -------------------------------------------------------------------------------- /ExportFrm.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #pragma hdrstop 5 | 6 | #include "ExportFrm.h" 7 | #include "MainFrm.h" 8 | #include "HexFrm.h" 9 | //--------------------------------------------------------------------------- 10 | #pragma package(smart_init) 11 | #pragma resource "*.dfm" 12 | TExportForm *ExportForm; 13 | //--------------------------------------------------------------------------- 14 | __fastcall TExportForm::TExportForm(TComponent* Owner) 15 | : TForm(Owner) 16 | { 17 | } 18 | //--------------------------------------------------------------------------- 19 | void __fastcall TExportForm::FormShow(TObject *Sender) 20 | { 21 | char OutputStr[1024]; 22 | 23 | 24 | ReverseOutputsCheckbox->Checked = MainForm->ReverseOutputs; 25 | ReverseWithinOutColCheckbox->Checked = MainForm->ReverseWithinOutCol; 26 | 27 | OutputBitOrderEdit->Text = MainForm->OutputBitOrderArrayToStr( OutputStr, sizeof(OutputStr) ); 28 | 29 | ROMLayoutRadioGroup->ItemIndex = MainForm->ROM_Layout; 30 | } 31 | //--------------------------------------------------------------------------- 32 | void __fastcall TExportForm::FormClose(TObject *Sender, 33 | TCloseAction &Action) 34 | { 35 | MainForm->ReverseOutputs = ReverseOutputsCheckbox->Checked; 36 | MainForm->ReverseWithinOutCol = ReverseWithinOutColCheckbox->Checked; 37 | MainForm->ROM_Layout = (rom_layout_type)ROMLayoutRadioGroup->ItemIndex; 38 | MainForm->Endianness = ExportForm->EndianRadioGroup->ItemIndex; 39 | 40 | if( ROMLayoutRadioGroup->ItemIndex < 2 ) 41 | EnableAdditionalOptions(); 42 | else 43 | DisableAdditionalOptions(); 44 | 45 | if( MainForm->ExportBin() > 0 ) // ByteData[] has been changed 46 | HexForm->UpdateBin( MainForm->ByteData, MainForm->ByteDataLen ); 47 | } 48 | //--------------------------------------------------------------------------- 49 | void __fastcall TExportForm::FormCloseQuery(TObject *Sender, 50 | bool &CanClose) 51 | { 52 | int i,n; 53 | char OutputStr[1024]; 54 | 55 | 56 | CanClose = true; 57 | 58 | if( MainForm->OutputBitOrderStrToArray( OutputBitOrderEdit->Text.c_str() ) < 1 ) 59 | { 60 | for( i=0; iNumOutputs; i++ ) 61 | MainForm->OutputOrder[i] = i; 62 | 63 | OutputBitOrderEdit->Text = MainForm->OutputBitOrderArrayToStr( OutputStr, sizeof(OutputStr) ); 64 | return; 65 | } 66 | 67 | // check if MainForm->OutputOrder[] is sane, if not popup dialog and offer to go back to edit it 68 | 69 | for( i=0; iNumOutputs; i++ ) 70 | { 71 | if( MainForm->OutputOrder[i] >= MainForm->NumOutputs ) 72 | break; 73 | for( n=0; nNumOutputs; n++ ) 74 | { 75 | if( MainForm->OutputOrder[n] == i ) 76 | break; 77 | } 78 | if( n >= MainForm->NumOutputs ) 79 | break; 80 | } 81 | if( i < MainForm->NumOutputs ) 82 | { 83 | if( Application->MessageBoxA( AnsiString(AnsiString("The Output bit order is not correct!\n\nThe Output bits include the range 0 .. ")+AnsiString( MainForm->NumOutputs-1 )+AnsiString("\n\nDo you want to continue even though the exported data will be invalid?") ).c_str(), "WARNING", MB_YESNO ) != IDYES ) 84 | CanClose = false; 85 | } 86 | } 87 | //--------------------------------------------------------------------------- 88 | void __fastcall TExportForm::ReverseOutputsCheckboxClick(TObject *Sender) 89 | { 90 | MainForm->ReverseOutputs = ReverseOutputsCheckbox->Checked; 91 | if( MainForm->ExportBin() > 0 ) // ByteData[] has been changed 92 | HexForm->UpdateBin( MainForm->ByteData, MainForm->ByteDataLen ); 93 | } 94 | //--------------------------------------------------------------------------- 95 | void __fastcall TExportForm::ReverseWithinOutColCheckboxClick( 96 | TObject *Sender) 97 | { 98 | MainForm->ReverseWithinOutCol = ReverseWithinOutColCheckbox->Checked; 99 | if( MainForm->ExportBin() > 0 ) // ByteData[] has been changed 100 | HexForm->UpdateBin( MainForm->ByteData, MainForm->ByteDataLen ); 101 | } 102 | //--------------------------------------------------------------------------- 103 | void __fastcall TExportForm::OutputBitOrderEditExit(TObject *Sender) 104 | { 105 | int i,n; 106 | 107 | 108 | MainForm->OutputBitOrderStrToArray( OutputBitOrderEdit->Text.c_str() ); 109 | 110 | // check if MainForm->OutputOrder[] is sane 111 | 112 | for( i=0; iNumOutputs; i++ ) 113 | { 114 | if( MainForm->OutputOrder[i] >= MainForm->NumOutputs ) 115 | break; 116 | for( n=0; nNumOutputs; n++ ) 117 | { 118 | if( MainForm->OutputOrder[n] == i ) 119 | break; 120 | } 121 | if( n >= MainForm->NumOutputs ) 122 | break; 123 | } 124 | if( i < MainForm->NumOutputs ) 125 | { 126 | if( Application->MessageBoxA( AnsiString(AnsiString("The Output bit order is not correct!\n\nThe Output bits include the range 0 .. ")+AnsiString( MainForm->NumOutputs-1 )+AnsiString("\n\nDo you want to continue even though the exported data will be invalid?") ).c_str(), "WARNING", MB_YESNO ) != IDYES ) 127 | return; 128 | } 129 | 130 | if( MainForm->ExportBin() > 0 ) // ByteData[] has been changed 131 | HexForm->UpdateBin( MainForm->ByteData, MainForm->ByteDataLen ); 132 | } 133 | //--------------------------------------------------------------------------- 134 | 135 | void __fastcall TExportForm::OutputBitOrderEditKeyPress(TObject *Sender, 136 | char &Key) 137 | { 138 | if( Key == '\r' ) 139 | { 140 | OutputBitOrderEditExit(Sender); 141 | } 142 | } 143 | //--------------------------------------------------------------------------- 144 | void __fastcall TExportForm::ROMLayoutRadioGroupClick(TObject *Sender) 145 | { 146 | MainForm->ROM_Layout = (rom_layout_type)ROMLayoutRadioGroup->ItemIndex; 147 | 148 | if( ROMLayoutRadioGroup->ItemIndex < 2 ) 149 | EnableAdditionalOptions(); 150 | else 151 | DisableAdditionalOptions(); 152 | 153 | if( MainForm->ExportBin() > 0 ) // ByteData[] has been changed 154 | HexForm->UpdateBin( MainForm->ByteData, MainForm->ByteDataLen ); 155 | } 156 | //--------------------------------------------------------------------------- 157 | void __fastcall TExportForm::DisableAdditionalOptions(void) 158 | { 159 | ReverseOutputsCheckbox->Enabled = false; 160 | ReverseWithinOutColCheckbox->Enabled = false; 161 | OutputBitOrderEdit->Enabled = false; 162 | OutputBitOrderLabel->Enabled = false; 163 | } 164 | //--------------------------------------------------------------------------- 165 | void __fastcall TExportForm::EnableAdditionalOptions(void) 166 | { 167 | ReverseOutputsCheckbox->Enabled = true; 168 | ReverseWithinOutColCheckbox->Enabled = true; 169 | OutputBitOrderEdit->Enabled = true; 170 | OutputBitOrderLabel->Enabled = true; 171 | } 172 | //--------------------------------------------------------------------------- 173 | void __fastcall TExportForm::EndianRadioGroupClick(TObject *Sender) 174 | { 175 | MainForm->Endianness = ExportForm->EndianRadioGroup->ItemIndex; 176 | 177 | if( MainForm->ExportBin() > 0 ) // ByteData[] has been changed 178 | HexForm->UpdateBin( MainForm->ByteData, MainForm->ByteDataLen ); 179 | } 180 | //--------------------------------------------------------------------------- 181 | 182 | -------------------------------------------------------------------------------- /ExportFrm.dfm: -------------------------------------------------------------------------------- 1 | object ExportForm: TExportForm 2 | Left = 553 3 | Top = 122 4 | Width = 651 5 | Height = 190 6 | Caption = 'Export options' 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'MS Sans Serif' 12 | Font.Style = [] 13 | FormStyle = fsStayOnTop 14 | OldCreateOrder = False 15 | OnClose = FormClose 16 | OnCloseQuery = FormCloseQuery 17 | OnShow = FormShow 18 | PixelsPerInch = 96 19 | TextHeight = 13 20 | object ROMLayoutRadioGroup: TRadioGroup 21 | Left = 8 22 | Top = 8 23 | Width = 225 24 | Height = 65 25 | Caption = 'ROM layout' 26 | ItemIndex = 0 27 | Items.Strings = ( 28 | 'Standard (1 bit per output column)' 29 | 'Mirrored halves (1 bit per output column)') 30 | TabOrder = 0 31 | OnClick = ROMLayoutRadioGroupClick 32 | end 33 | object AdditionalOptionsGroupBox: TGroupBox 34 | Left = 248 35 | Top = 8 36 | Width = 372 37 | Height = 113 38 | Caption = 'Additional options' 39 | TabOrder = 1 40 | object OutputBitOrderLabel: TLabel 41 | Left = 8 42 | Top = 84 43 | Width = 76 44 | Height = 13 45 | Caption = 'Output bit order:' 46 | end 47 | object ReverseOutputsCheckbox: TCheckBox 48 | Left = 16 49 | Top = 24 50 | Width = 297 51 | Height = 17 52 | Caption = 'Reverse output bit order (bit 0 = rightmost output column)' 53 | TabOrder = 0 54 | OnClick = ReverseOutputsCheckboxClick 55 | end 56 | object ReverseWithinOutColCheckbox: TCheckBox 57 | Left = 16 58 | Top = 48 59 | Width = 349 60 | Height = 17 61 | Caption = 62 | 'Addresses run right-to-left (byte 0 = rightmost bit within outpu' + 63 | 't column)' 64 | TabOrder = 1 65 | OnClick = ReverseWithinOutColCheckboxClick 66 | end 67 | object OutputBitOrderEdit: TEdit 68 | Left = 88 69 | Top = 80 70 | Width = 275 71 | Height = 21 72 | TabOrder = 2 73 | OnExit = OutputBitOrderEditExit 74 | OnKeyPress = OutputBitOrderEditKeyPress 75 | end 76 | end 77 | object EndianRadioGroup: TRadioGroup 78 | Left = 8 79 | Top = 96 80 | Width = 225 81 | Height = 49 82 | Caption = 'Endianness' 83 | ItemIndex = 1 84 | Items.Strings = ( 85 | 'Little endian (least significant byte first)' 86 | 'Big endian (most significant byte first)') 87 | TabOrder = 2 88 | OnClick = EndianRadioGroupClick 89 | end 90 | end 91 | -------------------------------------------------------------------------------- /ExportFrm.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef ExportFrmH 4 | #define ExportFrmH 5 | //--------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | //--------------------------------------------------------------------------- 13 | class TExportForm : public TForm 14 | { 15 | __published: // IDE-managed Components 16 | TRadioGroup *ROMLayoutRadioGroup; 17 | TGroupBox *AdditionalOptionsGroupBox; 18 | TLabel *OutputBitOrderLabel; 19 | TCheckBox *ReverseOutputsCheckbox; 20 | TCheckBox *ReverseWithinOutColCheckbox; 21 | TEdit *OutputBitOrderEdit; 22 | TRadioGroup *EndianRadioGroup; 23 | void __fastcall FormShow(TObject *Sender); 24 | void __fastcall FormClose(TObject *Sender, TCloseAction &Action); 25 | void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose); 26 | void __fastcall ReverseOutputsCheckboxClick(TObject *Sender); 27 | void __fastcall ReverseWithinOutColCheckboxClick(TObject *Sender); 28 | void __fastcall OutputBitOrderEditExit(TObject *Sender); 29 | void __fastcall OutputBitOrderEditKeyPress(TObject *Sender, char &Key); 30 | void __fastcall ROMLayoutRadioGroupClick(TObject *Sender); 31 | 32 | void __fastcall DisableAdditionalOptions(void); 33 | void __fastcall EnableAdditionalOptions(void); 34 | void __fastcall EndianRadioGroupClick(TObject *Sender); 35 | private: // User declarations 36 | public: // User declarations 37 | __fastcall TExportForm(TComponent* Owner); 38 | }; 39 | //--------------------------------------------------------------------------- 40 | extern PACKAGE TExportForm *ExportForm; 41 | //--------------------------------------------------------------------------- 42 | #endif 43 | -------------------------------------------------------------------------------- /HexFrm.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #pragma hdrstop 5 | 6 | #include "HexFrm.h" 7 | #include "MainFrm.h" 8 | //--------------------------------------------------------------------------- 9 | #pragma package(smart_init) 10 | #pragma resource "*.dfm" 11 | THexForm *HexForm; 12 | //--------------------------------------------------------------------------- 13 | __fastcall THexForm::THexForm(TComponent* Owner) 14 | : TForm(Owner) 15 | { 16 | PrevByteData=NULL; 17 | PrevByteDataLen=0; 18 | } 19 | //--------------------------------------------------------------------------- 20 | void __fastcall THexForm::UpdateBin( unsigned char *ByteData, int ByteDataLen ) 21 | { 22 | int i; 23 | int LineNum; 24 | AnsiString HexLine; 25 | AnsiString AsciiLine; 26 | int AddrDigits = AnsiString().sprintf("%X",ByteDataLen).Length(); 27 | int CurSelStart,CurSelLength; 28 | 29 | 30 | if( AddrDigits < 4 ) 31 | AddrDigits = 4; 32 | CurSelStart = HexMemo->SelStart; 33 | CurSelLength = HexMemo->SelLength; 34 | HexMemo->Lines->BeginUpdate(); 35 | HexMemo->Lines->Clear(); 36 | for( i=0,LineNum=0; iLines->Count <= LineNum ) 46 | HexMemo->Lines->Add(HexLine); 47 | else if( HexMemo->Lines->Strings[LineNum] != HexLine ) 48 | HexMemo->Lines->Strings[LineNum] = HexLine; 49 | LineNum++; 50 | } 51 | 52 | HexLine.sprintf( "%0*X:", AddrDigits, i ); 53 | AsciiLine=""; 54 | } 55 | 56 | //TODO - add colouring to changed bytes/nibbles 57 | // if( i>=PrevByteDataLen || ByteData[i] != PrevByteData[i] ) 58 | // HexLine.cat_sprintf("`%02X", ByteData[i] ); 59 | // else 60 | // HexLine.cat_sprintf(" %02X", ByteData[i] ); 61 | 62 | HexLine.cat_sprintf(" %02X", ByteData[i] ); 63 | AsciiLine.cat_sprintf("%c", ByteData[i]>=0x20 && ByteData[i]<0x7F ? ByteData[i] : '.' ); 64 | } 65 | 66 | for( ; i%0x10; i++ ) 67 | HexLine.cat_sprintf(" "); 68 | 69 | HexLine += " "; 70 | HexLine += AsciiLine; 71 | if( HexMemo->Lines->Count <= LineNum ) 72 | HexMemo->Lines->Add(HexLine); 73 | else if( HexMemo->Lines->Strings[LineNum] != HexLine ) 74 | HexMemo->Lines->Strings[LineNum] = HexLine; 75 | LineNum++; 76 | 77 | HexMemo->Lines->EndUpdate(); 78 | HexMemo->SelStart = CurSelStart; 79 | HexMemo->SelLength = CurSelLength; 80 | HexMemo->Perform(EM_SCROLLCARET, 0, 0); 81 | 82 | HexMemo->Update(); 83 | 84 | if( ByteDataLen != PrevByteDataLen ) 85 | { 86 | PrevByteDataLen = ByteDataLen; 87 | PrevByteData = new unsigned char[ PrevByteDataLen ]; 88 | memset( PrevByteData, 0, PrevByteDataLen ); 89 | } 90 | memmove(PrevByteData,ByteData,ByteDataLen); 91 | PrevByteDataLen = ByteDataLen; 92 | } 93 | //--------------------------------------------------------------------------- 94 | void __fastcall THexForm::HexMemoKeyPress(TObject *Sender, char &Key) 95 | { 96 | Key = 0; 97 | } 98 | //--------------------------------------------------------------------------- 99 | void __fastcall THexForm::Updatebyteview1Click(TObject *Sender) 100 | { 101 | UpdateBin( PrevByteData, PrevByteDataLen ); 102 | } 103 | //--------------------------------------------------------------------------- 104 | void __fastcall THexForm::Copy1Click(TObject *Sender) 105 | { 106 | HexMemo->CopyToClipboard(); 107 | } 108 | //--------------------------------------------------------------------------- 109 | void __fastcall THexForm::Savebinfile1Click(TObject *Sender) 110 | { 111 | MainForm->SaveBinButtonClick(Sender); 112 | } 113 | //--------------------------------------------------------------------------- 114 | -------------------------------------------------------------------------------- /HexFrm.dfm: -------------------------------------------------------------------------------- 1 | object HexForm: THexForm 2 | Left = 554 3 | Top = 113 4 | Width = 625 5 | Height = 407 6 | Caption = 'Byte view' 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'MS Sans Serif' 12 | Font.Style = [] 13 | OldCreateOrder = False 14 | PixelsPerInch = 96 15 | TextHeight = 13 16 | object HexMemo: TRichEdit 17 | Left = 0 18 | Top = 0 19 | Width = 609 20 | Height = 369 21 | Align = alClient 22 | Color = clBlack 23 | Font.Charset = ANSI_CHARSET 24 | Font.Color = clSilver 25 | Font.Height = -13 26 | Font.Name = 'Courier New' 27 | Font.Style = [] 28 | ParentFont = False 29 | PopupMenu = PopupMenu1 30 | ScrollBars = ssVertical 31 | TabOrder = 0 32 | WordWrap = False 33 | OnKeyPress = HexMemoKeyPress 34 | end 35 | object PopupMenu1: TPopupMenu 36 | Left = 192 37 | Top = 48 38 | object Updatebyteview1: TMenuItem 39 | Caption = '&Redraw byte view' 40 | OnClick = Updatebyteview1Click 41 | end 42 | object Copy1: TMenuItem 43 | Caption = '&Copy selection' 44 | OnClick = Copy1Click 45 | end 46 | object Savebinfile1: TMenuItem 47 | Caption = '&Save .bin file...' 48 | OnClick = Savebinfile1Click 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /HexFrm.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef HexFrmH 4 | #define HexFrmH 5 | //--------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | //--------------------------------------------------------------------------- 13 | class THexForm : public TForm 14 | { 15 | __published: // IDE-managed Components 16 | TRichEdit *HexMemo; 17 | TPopupMenu *PopupMenu1; 18 | TMenuItem *Updatebyteview1; 19 | TMenuItem *Copy1; 20 | TMenuItem *Savebinfile1; 21 | void __fastcall HexMemoKeyPress(TObject *Sender, char &Key); 22 | void __fastcall Updatebyteview1Click(TObject *Sender); 23 | void __fastcall Copy1Click(TObject *Sender); 24 | void __fastcall Savebinfile1Click(TObject *Sender); 25 | private: // User declarations 26 | public: // User declarations 27 | __fastcall THexForm(TComponent* Owner); 28 | 29 | void __fastcall UpdateBin( unsigned char *ByteData, int ByteDataLen ); 30 | 31 | unsigned char *PrevByteData; 32 | int PrevByteDataLen; 33 | }; 34 | //--------------------------------------------------------------------------- 35 | extern PACKAGE THexForm *HexForm; 36 | //--------------------------------------------------------------------------- 37 | #endif 38 | -------------------------------------------------------------------------------- /HistogramFrm.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #pragma hdrstop 5 | 6 | #include "HistogramFrm.h" 7 | #include "ImageFrm.h" 8 | #include "ROMBitSettingsFrm.h" 9 | //--------------------------------------------------------------------------- 10 | #pragma package(smart_init) 11 | #pragma link "histogrambox" 12 | #pragma resource "*.dfm" 13 | THistogramForm *HistogramForm; 14 | //--------------------------------------------------------------------------- 15 | __fastcall THistogramForm::THistogramForm(TComponent* Owner) 16 | : TForm(Owner) 17 | { 18 | } 19 | //--------------------------------------------------------------------------- 20 | void __fastcall THistogramForm::HistogramBoxClick(TObject *Sender) 21 | { 22 | HistogramBox->Update(); 23 | } 24 | //--------------------------------------------------------------------------- 25 | void __fastcall THistogramForm::FormCreate(TObject *Sender) 26 | { 27 | // read .ini file to setup form (x/y position etc) 28 | TIniFile *BitractIni; 29 | 30 | BitractIni = new TIniFile( ChangeFileExt( Application->ExeName, ".ini" ) ); 31 | Top = BitractIni->ReadInteger( "HistogramForm", "Top", ROMBitSettingsForm->Top+ROMBitSettingsForm->Height ); // HistogramForm goes below ObjectiveForm (on top of ImageForm) 32 | Left = BitractIni->ReadInteger( "HistogramForm", "Left", 0 ); 33 | Width = BitractIni->ReadInteger( "HistogramForm", "Width", Width ); 34 | Height = BitractIni->ReadInteger( "HistogramForm", "Height", Height ); 35 | 36 | delete BitractIni; 37 | } 38 | //--------------------------------------------------------------------------- 39 | void __fastcall THistogramForm::FormDestroy(TObject *Sender) 40 | { 41 | // write .ini file to save form setup (x/y position etc) 42 | TIniFile *BitractIni; 43 | 44 | BitractIni = new TIniFile( ChangeFileExt( Application->ExeName, ".ini" ) ); 45 | BitractIni->WriteInteger( "HistogramForm", "Top", Top ); // save top/left of form 46 | BitractIni->WriteInteger( "HistogramForm", "Left", Left ); 47 | BitractIni->WriteInteger( "HistogramForm", "Width", Width ); // save width/height of form 48 | BitractIni->WriteInteger( "HistogramForm", "Height", Height ); 49 | 50 | delete BitractIni; 51 | } 52 | //--------------------------------------------------------------------------- 53 | void __fastcall THistogramForm::FormResize(TObject *Sender) 54 | { 55 | if( Width > 320 ) 56 | HistogramBox->Width = Width-315; 57 | } 58 | //--------------------------------------------------------------------------- 59 | -------------------------------------------------------------------------------- /HistogramFrm.dfm: -------------------------------------------------------------------------------- 1 | object HistogramForm: THistogramForm 2 | Left = 328 3 | Top = 117 4 | Width = 459 5 | Height = 146 6 | Caption = 'Image histogram' 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'MS Sans Serif' 12 | Font.Style = [] 13 | OldCreateOrder = False 14 | Visible = True 15 | OnCreate = FormCreate 16 | OnDestroy = FormDestroy 17 | OnResize = FormResize 18 | DesignSize = ( 19 | 443 20 | 108) 21 | PixelsPerInch = 96 22 | TextHeight = 13 23 | object Label1: TLabel 24 | Left = 174 25 | Top = 8 26 | Width = 64 27 | Height = 13 28 | Anchors = [akTop, akRight] 29 | Caption = 'Pixels at 0:' 30 | Font.Charset = DEFAULT_CHARSET 31 | Font.Color = clWindowText 32 | Font.Height = -11 33 | Font.Name = 'MS Sans Serif' 34 | Font.Style = [fsBold] 35 | ParentFont = False 36 | end 37 | object Label2: TLabel 38 | Left = 160 39 | Top = 32 40 | Width = 78 41 | Height = 13 42 | Anchors = [akTop, akRight] 43 | Caption = 'Pixels at 255:' 44 | Font.Charset = DEFAULT_CHARSET 45 | Font.Color = clWindowText 46 | Font.Height = -11 47 | Font.Name = 'MS Sans Serif' 48 | Font.Style = [fsBold] 49 | ParentFont = False 50 | end 51 | object PixelsAt0RLabel: TLabel 52 | Left = 256 53 | Top = 8 54 | Width = 35 55 | Height = 13 56 | Alignment = taRightJustify 57 | Anchors = [akTop, akRight] 58 | AutoSize = False 59 | Caption = '0' 60 | end 61 | object PixelsAt0GLabel: TLabel 62 | Left = 328 63 | Top = 8 64 | Width = 35 65 | Height = 13 66 | Alignment = taRightJustify 67 | Anchors = [akTop, akRight] 68 | AutoSize = False 69 | Caption = '0' 70 | end 71 | object PixelsAt0BLabel: TLabel 72 | Left = 394 73 | Top = 8 74 | Width = 35 75 | Height = 13 76 | Alignment = taRightJustify 77 | Anchors = [akTop, akRight] 78 | AutoSize = False 79 | Caption = '0' 80 | end 81 | object PixelsAt255RLabel: TLabel 82 | Left = 256 83 | Top = 32 84 | Width = 35 85 | Height = 13 86 | Alignment = taRightJustify 87 | Anchors = [akTop, akRight] 88 | AutoSize = False 89 | Caption = '0' 90 | end 91 | object PixelsAt255GLabel: TLabel 92 | Left = 328 93 | Top = 32 94 | Width = 35 95 | Height = 13 96 | Alignment = taRightJustify 97 | Anchors = [akTop, akRight] 98 | AutoSize = False 99 | Caption = '0' 100 | end 101 | object PixelsAt255BLabel: TLabel 102 | Left = 394 103 | Top = 32 104 | Width = 35 105 | Height = 13 106 | Alignment = taRightJustify 107 | Anchors = [akTop, akRight] 108 | AutoSize = False 109 | Caption = '0' 110 | end 111 | object Label3: TLabel 112 | Left = 177 113 | Top = 64 114 | Width = 61 115 | Height = 13 116 | Anchors = [akTop, akRight] 117 | Caption = 'Pixels min:' 118 | Font.Charset = DEFAULT_CHARSET 119 | Font.Color = clWindowText 120 | Font.Height = -11 121 | Font.Name = 'MS Sans Serif' 122 | Font.Style = [fsBold] 123 | ParentFont = False 124 | end 125 | object PixelsMinRLabel: TLabel 126 | Left = 265 127 | Top = 64 128 | Width = 25 129 | Height = 13 130 | Alignment = taRightJustify 131 | Anchors = [akTop, akRight] 132 | AutoSize = False 133 | Caption = '0' 134 | end 135 | object PixelsMinGLabel: TLabel 136 | Left = 338 137 | Top = 64 138 | Width = 25 139 | Height = 13 140 | Alignment = taRightJustify 141 | Anchors = [akTop, akRight] 142 | AutoSize = False 143 | Caption = '0' 144 | end 145 | object PixelsMinBLabel: TLabel 146 | Left = 406 147 | Top = 64 148 | Width = 23 149 | Height = 13 150 | Alignment = taRightJustify 151 | Anchors = [akTop, akRight] 152 | AutoSize = False 153 | Caption = '0' 154 | end 155 | object Label4: TLabel 156 | Left = 174 157 | Top = 88 158 | Width = 64 159 | Height = 13 160 | Anchors = [akTop, akRight] 161 | Caption = 'Pixels max:' 162 | Font.Charset = DEFAULT_CHARSET 163 | Font.Color = clWindowText 164 | Font.Height = -11 165 | Font.Name = 'MS Sans Serif' 166 | Font.Style = [fsBold] 167 | ParentFont = False 168 | end 169 | object PixelsMaxRLabel: TLabel 170 | Left = 265 171 | Top = 88 172 | Width = 25 173 | Height = 13 174 | Alignment = taRightJustify 175 | Anchors = [akTop, akRight] 176 | AutoSize = False 177 | Caption = '0' 178 | end 179 | object PixelsMaxGLabel: TLabel 180 | Left = 338 181 | Top = 88 182 | Width = 25 183 | Height = 13 184 | Alignment = taRightJustify 185 | Anchors = [akTop, akRight] 186 | AutoSize = False 187 | Caption = '0' 188 | end 189 | object PixelsMaxBLabel: TLabel 190 | Left = 406 191 | Top = 88 192 | Width = 23 193 | Height = 13 194 | Alignment = taRightJustify 195 | Anchors = [akTop, akRight] 196 | AutoSize = False 197 | Caption = '0' 198 | end 199 | object Label5: TLabel 200 | Left = 393 201 | Top = 64 202 | Width = 10 203 | Height = 13 204 | Anchors = [akTop, akRight] 205 | Caption = 'B:' 206 | end 207 | object Label6: TLabel 208 | Left = 384 209 | Top = 32 210 | Width = 10 211 | Height = 13 212 | Anchors = [akTop, akRight] 213 | Caption = 'B:' 214 | end 215 | object Label7: TLabel 216 | Left = 384 217 | Top = 8 218 | Width = 10 219 | Height = 13 220 | Anchors = [akTop, akRight] 221 | Caption = 'B:' 222 | end 223 | object Label8: TLabel 224 | Left = 393 225 | Top = 88 226 | Width = 10 227 | Height = 13 228 | Anchors = [akTop, akRight] 229 | Caption = 'B:' 230 | end 231 | object Label9: TLabel 232 | Left = 326 233 | Top = 88 234 | Width = 11 235 | Height = 13 236 | Anchors = [akTop, akRight] 237 | Caption = 'G:' 238 | end 239 | object Label10: TLabel 240 | Left = 326 241 | Top = 64 242 | Width = 11 243 | Height = 13 244 | Anchors = [akTop, akRight] 245 | Caption = 'G:' 246 | end 247 | object Label11: TLabel 248 | Left = 318 249 | Top = 32 250 | Width = 11 251 | Height = 13 252 | Anchors = [akTop, akRight] 253 | Caption = 'G:' 254 | end 255 | object Label12: TLabel 256 | Left = 318 257 | Top = 8 258 | Width = 11 259 | Height = 13 260 | Anchors = [akTop, akRight] 261 | Caption = 'G:' 262 | end 263 | object Label13: TLabel 264 | Left = 252 265 | Top = 88 266 | Width = 11 267 | Height = 13 268 | Anchors = [akTop, akRight] 269 | Caption = 'R:' 270 | end 271 | object Label14: TLabel 272 | Left = 252 273 | Top = 64 274 | Width = 11 275 | Height = 13 276 | Anchors = [akTop, akRight] 277 | Caption = 'R:' 278 | end 279 | object Label15: TLabel 280 | Left = 244 281 | Top = 32 282 | Width = 11 283 | Height = 13 284 | Anchors = [akTop, akRight] 285 | Caption = 'R:' 286 | end 287 | object Label16: TLabel 288 | Left = 244 289 | Top = 8 290 | Width = 11 291 | Height = 13 292 | Anchors = [akTop, akRight] 293 | Caption = 'R:' 294 | end 295 | object HistogramBox: THistogramBox 296 | Left = 0 297 | Top = 0 298 | Width = 145 299 | Height = 108 300 | AttachedImageEnProc = ImageForm.ImageProc 301 | HistogramKind = [hkRed, hkGreen, hkBlue] 302 | Align = alLeft 303 | OnClick = HistogramBoxClick 304 | end 305 | end 306 | -------------------------------------------------------------------------------- /HistogramFrm.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef HistogramFrmH 4 | #define HistogramFrmH 5 | //--------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "histogrambox.hpp" 11 | //--------------------------------------------------------------------------- 12 | class THistogramForm : public TForm 13 | { 14 | __published: // IDE-managed Components 15 | THistogramBox *HistogramBox; 16 | TLabel *Label1; 17 | TLabel *Label2; 18 | TLabel *PixelsAt0RLabel; 19 | TLabel *PixelsAt0GLabel; 20 | TLabel *PixelsAt0BLabel; 21 | TLabel *PixelsAt255RLabel; 22 | TLabel *PixelsAt255GLabel; 23 | TLabel *PixelsAt255BLabel; 24 | TLabel *Label3; 25 | TLabel *PixelsMinRLabel; 26 | TLabel *PixelsMinGLabel; 27 | TLabel *PixelsMinBLabel; 28 | TLabel *Label4; 29 | TLabel *PixelsMaxRLabel; 30 | TLabel *PixelsMaxGLabel; 31 | TLabel *PixelsMaxBLabel; 32 | TLabel *Label5; 33 | TLabel *Label6; 34 | TLabel *Label7; 35 | TLabel *Label8; 36 | TLabel *Label9; 37 | TLabel *Label10; 38 | TLabel *Label11; 39 | TLabel *Label12; 40 | TLabel *Label13; 41 | TLabel *Label14; 42 | TLabel *Label15; 43 | TLabel *Label16; 44 | void __fastcall HistogramBoxClick(TObject *Sender); 45 | void __fastcall FormCreate(TObject *Sender); 46 | void __fastcall FormDestroy(TObject *Sender); 47 | void __fastcall FormResize(TObject *Sender); 48 | private: // User declarations 49 | public: // User declarations 50 | __fastcall THistogramForm(TComponent* Owner); 51 | }; 52 | //--------------------------------------------------------------------------- 53 | extern PACKAGE THistogramForm *HistogramForm; 54 | //--------------------------------------------------------------------------- 55 | #endif 56 | -------------------------------------------------------------------------------- /ImageFrm.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #include 5 | #include 6 | #pragma hdrstop 7 | 8 | #include "ImageFrm.h" 9 | #include "HistogramFrm.h" 10 | #include "LogFrm.h" 11 | #include "ROMBitSettingsFrm.h" 12 | //--------------------------------------------------------------------------- 13 | #pragma package(smart_init) 14 | #pragma link "ieview" 15 | #pragma link "imageenio" 16 | #pragma link "imageenview" 17 | #pragma link "imageenproc" 18 | #pragma link "ievect" 19 | #pragma resource "*.dfm" 20 | TImageForm *ImageForm; 21 | //--------------------------------------------------------------------------- 22 | __fastcall TImageForm::TImageForm(TComponent* Owner) 23 | : TForm(Owner) 24 | { 25 | MultiplierR=NULL; 26 | MultiplierG=NULL; 27 | MultiplierB=NULL; 28 | 29 | ROMPolygon=-1; 30 | 31 | ROMBit=NULL; 32 | NumROMBits=0; 33 | 34 | OpenFilename=""; 35 | WorkingDir=""; 36 | PreviousFilename=""; 37 | 38 | XBoxesPatternLen=0; 39 | XBoxesPattern=NULL; 40 | YBoxesPatternLen=0; 41 | YBoxesPattern=NULL; 42 | } 43 | //--------------------------------------------------------------------------- 44 | void __fastcall TImageForm::Saveimageas1Click(TObject *Sender) 45 | { 46 | if( WorkingDir.Length() && SaveImageDialog->InitialDir != WorkingDir ) 47 | { 48 | SaveImageDialog->InitialDir = WorkingDir; 49 | SaveImageDialog->FileName = ""; 50 | } 51 | if( SaveImageDialog->Execute() != mrOk ) 52 | return; 53 | 54 | WorkingDir = SaveImageDialog->FileName.SubString(1, SaveImageDialog->FileName.LastDelimiter( ":\\" ) ); 55 | 56 | ImageView->IO->SaveToFile( SaveImageDialog->FileName ); 57 | } 58 | //--------------------------------------------------------------------------- 59 | void __fastcall TImageForm::FormCreate(TObject *Sender) 60 | { 61 | // read .ini file to setup form (x/y position etc) 62 | TIniFile *PicturizatronIni; 63 | 64 | PicturizatronIni = new TIniFile( ChangeFileExt( Application->ExeName, ".ini" ) ); 65 | Top = PicturizatronIni->ReadInteger( "ImageForm", "Top", 0 ); 66 | Left = PicturizatronIni->ReadInteger( "ImageForm", "Left", LogForm->Left + LogForm->Width ); 67 | Width = PicturizatronIni->ReadInteger( "ImageForm", "Width", Width ); 68 | Height = PicturizatronIni->ReadInteger( "ImageForm", "Height", Height ); 69 | 70 | WorkingDir = PicturizatronIni->ReadString( "Image", "WorkingDir", "" ); 71 | 72 | LoadSettings( ChangeFileExt( Application->ExeName, ".ini" ) ); 73 | 74 | delete PicturizatronIni; 75 | } 76 | //--------------------------------------------------------------------------- 77 | void __fastcall TImageForm::FormDestroy(TObject *Sender) 78 | { 79 | if(ROMBit) 80 | delete[] ROMBit; 81 | ROMBit=NULL; 82 | NumROMBits=0; 83 | 84 | // write .ini file to save form setup (x/y position etc) 85 | TIniFile *PicturizatronIni; 86 | 87 | PicturizatronIni = new TIniFile( ChangeFileExt( Application->ExeName, ".ini" ) ); 88 | PicturizatronIni->WriteInteger( "ImageForm", "Top", Top ); // save top/left of form 89 | PicturizatronIni->WriteInteger( "ImageForm", "Left", Left ); 90 | PicturizatronIni->WriteInteger( "ImageForm", "Width", Width ); // save width/height of form 91 | PicturizatronIni->WriteInteger( "ImageForm", "Height", Height ); 92 | 93 | PicturizatronIni->WriteString( "Image", "WorkingDir", WorkingDir ); 94 | 95 | delete PicturizatronIni; 96 | 97 | SaveSettings( ChangeFileExt( Application->ExeName, ".ini" ) ); 98 | 99 | XBoxesPatternLen=0; 100 | if( XBoxesPattern ) 101 | delete[] XBoxesPattern; 102 | XBoxesPattern=NULL; 103 | YBoxesPatternLen=0; 104 | if( YBoxesPattern ) 105 | delete[] YBoxesPattern; 106 | YBoxesPattern=NULL; 107 | } 108 | //--------------------------------------------------------------------------- 109 | void __fastcall TImageForm::Zoom1001Click(TObject *Sender) 110 | { 111 | ImageView->Zoom = 100.0; 112 | UpdateCaption(); 113 | } 114 | //--------------------------------------------------------------------------- 115 | void __fastcall TImageForm::ImageViewZoomIn(TObject *Sender, 116 | double &NewZoom) 117 | { 118 | UpdateCaption(); 119 | } 120 | //--------------------------------------------------------------------------- 121 | void __fastcall TImageForm::ImageViewZoomOut(TObject *Sender, 122 | double &NewZoom) 123 | { 124 | UpdateCaption(); 125 | } 126 | //--------------------------------------------------------------------------- 127 | void __fastcall TImageForm::UpdateCaption(void) 128 | { 129 | Caption = (AnsiString)"Image "+ImageView->IEBitmap->Width+"x"+ImageView->IEBitmap->Height+" ["+RoundTo(ImageView->Zoom,0)+"\%]"; 130 | } 131 | //--------------------------------------------------------------------------- 132 | void __fastcall TImageForm::ImageViewImageChange(TObject *Sender) 133 | { 134 | THistogram ImageHistogram; 135 | 136 | 137 | HistogramForm->HistogramBox->Update(); 138 | 139 | ImageView->Proc->GetHistogram( &ImageHistogram ); 140 | 141 | HistogramForm->PixelsAt0RLabel->Caption = ImageHistogram[0].R; 142 | HistogramForm->PixelsAt0GLabel->Caption = ImageHistogram[0].G; 143 | HistogramForm->PixelsAt0BLabel->Caption = ImageHistogram[0].B; 144 | 145 | HistogramForm->PixelsAt255RLabel->Caption = ImageHistogram[255].R; 146 | HistogramForm->PixelsAt255GLabel->Caption = ImageHistogram[255].G; 147 | HistogramForm->PixelsAt255BLabel->Caption = ImageHistogram[255].B; 148 | 149 | 150 | int MinR,MinG,MinB; 151 | int MaxR,MaxG,MaxB; 152 | 153 | for(MinR=0; !ImageHistogram[MinR].R; MinR++) 154 | ; 155 | for(MinG=0; !ImageHistogram[MinG].G; MinG++) 156 | ; 157 | for(MinB=0; !ImageHistogram[MinB].B; MinB++) 158 | ; 159 | 160 | for(MaxR=255; !ImageHistogram[MaxR].R; MaxR--) 161 | ; 162 | for(MaxG=255; !ImageHistogram[MaxG].G; MaxG--) 163 | ; 164 | for(MaxB=255; !ImageHistogram[MaxB].B; MaxB--) 165 | ; 166 | 167 | HistogramForm->PixelsMinRLabel->Caption = MinR; 168 | HistogramForm->PixelsMinGLabel->Caption = MinG; 169 | HistogramForm->PixelsMinBLabel->Caption = MinB; 170 | 171 | HistogramForm->PixelsMaxRLabel->Caption = MaxR; 172 | HistogramForm->PixelsMaxGLabel->Caption = MaxG; 173 | HistogramForm->PixelsMaxBLabel->Caption = MaxB; 174 | 175 | UpdateCaption(); 176 | } 177 | //--------------------------------------------------------------------------- 178 | void __fastcall TImageForm::Calcmultipliers1Click(TObject *Sender) 179 | { 180 | THistogram RefHisto; 181 | TRGB RefMin, RefMax; 182 | int RowCounter,ColCounter; 183 | 184 | 185 | ImageView->Cursor = crHourGlass; 186 | ImageView->Update(); 187 | 188 | // get reference image histogram 189 | ImageView->Proc->GetHistogram( &RefHisto ); 190 | 191 | // calc RefMin.r 192 | for( RefMin.r=0; RefMin.r<255; RefMin.r++ ) 193 | if( RefHisto[ RefMin.r ].R ) 194 | break; 195 | 196 | // calc RefMax.r 197 | for( RefMax.r=255; RefMax.r; RefMax.r-- ) 198 | if( RefHisto[ RefMax.r ].R ) 199 | break; 200 | 201 | // calc RefMin.g 202 | for( RefMin.g=0; RefMin.g<255; RefMin.g++ ) 203 | if( RefHisto[ RefMin.g ].G ) 204 | break; 205 | 206 | // calc RefMax.g 207 | for( RefMax.g=255; RefMax.g; RefMax.g-- ) 208 | if( RefHisto[ RefMax.g ].G ) 209 | break; 210 | 211 | // calc RefMin.b 212 | for( RefMin.b=0; RefMin.b<255; RefMin.b++ ) 213 | if( RefHisto[ RefMin.b ].B ) 214 | break; 215 | 216 | // calc RefMax.b 217 | for( RefMax.b=255; RefMax.b; RefMax.b-- ) 218 | if( RefHisto[ RefMax.b ].B ) 219 | break; 220 | 221 | 222 | // LogForm->LogMemo->Lines->Add( (AnsiString)"min: "+RefMin.r+" "+RefMin.g+" "+RefMin.b ); 223 | // LogForm->LogMemo->Lines->Add( (AnsiString)"max: "+RefMax.r+" "+RefMax.g+" "+RefMax.b ); 224 | 225 | 226 | if( MultiplierR ) 227 | delete[] MultiplierR; 228 | if( MultiplierG ) 229 | delete[] MultiplierG; 230 | if( MultiplierB ) 231 | delete[] MultiplierB; 232 | 233 | MultiplierR = new double[ImageView->IEBitmap->Width * ImageView->IEBitmap->Height]; 234 | MultiplierG = new double[ImageView->IEBitmap->Width * ImageView->IEBitmap->Height]; 235 | MultiplierB = new double[ImageView->IEBitmap->Width * ImageView->IEBitmap->Height]; 236 | 237 | 238 | // loop to calculate Multiplier[] values 239 | for( RowCounter=0; RowCounterIEBitmap->Height; RowCounter++ ) 240 | { 241 | for( ColCounter=0; ColCounterIEBitmap->Width; ColCounter++ ) 242 | { 243 | MultiplierR[ (RowCounter*ImageView->IEBitmap->Width)+ColCounter ] = ( (double)RefMax.r / (double)ImageView->IEBitmap->Pixels_ie24RGB[ColCounter][RowCounter].r ); 244 | MultiplierG[ (RowCounter*ImageView->IEBitmap->Width)+ColCounter ] = ( (double)RefMax.g / (double)ImageView->IEBitmap->Pixels_ie24RGB[ColCounter][RowCounter].g ); 245 | MultiplierB[ (RowCounter*ImageView->IEBitmap->Width)+ColCounter ] = ( (double)RefMax.b / (double)ImageView->IEBitmap->Pixels_ie24RGB[ColCounter][RowCounter].b ); 246 | } 247 | } 248 | 249 | 250 | // done 251 | ImageView->Cursor = crDefault; 252 | ImageView->Update(); 253 | } 254 | //--------------------------------------------------------------------------- 255 | void __fastcall TImageForm::ApplyMultipliersButtonClick(TObject *Sender) 256 | { 257 | int RowCounter,ColCounter; 258 | int NewPixelValue; 259 | int MaxR=0,MaxG=0,MaxB=0; 260 | int CutR=0,CutG=0,CutB=0; 261 | 262 | if( !MultiplierR || !MultiplierG || !MultiplierB ) 263 | return; 264 | 265 | ImageView->Cursor = crHourGlass; 266 | ImageView->Update(); 267 | 268 | 269 | // loop to apply Multiplier[] values 270 | for( RowCounter=0; RowCounterIEBitmap->Height; RowCounter++ ) 271 | { 272 | // if( !RowCounter%50 ) 273 | // ImageView->Update(); 274 | 275 | 276 | for( ColCounter=0; ColCounterIEBitmap->Width; ColCounter++ ) 277 | { 278 | NewPixelValue = (double)ImageView->IEBitmap->Pixels_ie24RGB[ColCounter][RowCounter].r * MultiplierR[ (RowCounter*ImageView->IEBitmap->Width)+ColCounter ]; 279 | if( NewPixelValue > 0xFF ) 280 | { 281 | CutR++; 282 | if(NewPixelValue>MaxR) 283 | MaxR=NewPixelValue; 284 | NewPixelValue = 0xFF; 285 | } 286 | (*ImageView->IEBitmap->PPixels_ie24RGB[ColCounter][RowCounter]).r = NewPixelValue; 287 | 288 | NewPixelValue = (double)ImageView->IEBitmap->Pixels_ie24RGB[ColCounter][RowCounter].g * MultiplierG[ (RowCounter*ImageView->IEBitmap->Width)+ColCounter ]; 289 | if( NewPixelValue > 0xFF ) 290 | { 291 | CutG++; 292 | if(NewPixelValue>MaxG) 293 | MaxG=NewPixelValue; 294 | NewPixelValue = 0xFF; 295 | } 296 | (*ImageView->IEBitmap->PPixels_ie24RGB[ColCounter][RowCounter]).g = NewPixelValue; 297 | 298 | NewPixelValue = (double)ImageView->IEBitmap->Pixels_ie24RGB[ColCounter][RowCounter].b * MultiplierB[ (RowCounter*ImageView->IEBitmap->Width)+ColCounter ]; 299 | if( NewPixelValue > 0xFF ) 300 | { 301 | CutB++; 302 | if(NewPixelValue>MaxB) 303 | MaxB=NewPixelValue; 304 | NewPixelValue = 0xFF; 305 | } 306 | (*ImageView->IEBitmap->PPixels_ie24RGB[ColCounter][RowCounter]).b = NewPixelValue; 307 | } 308 | } 309 | 310 | // done 311 | ImageView->Cursor = crDefault; 312 | Update(); 313 | 314 | // LogForm->LogMemo->Lines->Add( (AnsiString)CutR+" "+CutG+" "+CutB ); 315 | // LogForm->LogMemo->Lines->Add( (AnsiString)MaxR+" "+MaxG+" "+MaxB ); 316 | } 317 | //--------------------------------------------------------------------------- 318 | void __fastcall TImageForm::OpenImageButtonClick(TObject *Sender) 319 | { 320 | if( WorkingDir.Length() && OpenImageDialog->InitialDir != WorkingDir ) 321 | { 322 | OpenImageDialog->InitialDir = WorkingDir; 323 | OpenImageDialog->FileName = ""; 324 | } 325 | 326 | if( OpenImageDialog->Execute() != mrOk ) 327 | return; 328 | 329 | WorkingDir = OpenImageDialog->FileName.SubString(1, OpenImageDialog->FileName.LastDelimiter( ":\\" ) ); 330 | 331 | OpenFilename = OpenImageDialog->FileName; 332 | ImageView->IO->LoadFromFile( OpenFilename.c_str() ); 333 | 334 | LogForm->LogMemo->Lines->Add("Image loaded - Select \"Area Of Interest -> Show Area Of Interest overlay\" to set the area of interest."); 335 | LogForm->LogMemo->Lines->Add(""); 336 | } 337 | //--------------------------------------------------------------------------- 338 | void __fastcall TImageForm::ShowROMBox1Click(TObject *Sender) 339 | { 340 | int i; 341 | int minx,miny; 342 | 343 | 344 | if(ROMPolygon > -1) 345 | { // ROMPolygon already exists - delete objects before recreating it 346 | Clearallobjects1Click(Sender); 347 | ImageView->UnSelAllObjects(); 348 | ImageView->OnVectorialChanged = NULL; 349 | ImageView->RemoveAllObjects(); 350 | ROMPolygon = -1; 351 | ImageView->OnVectorialChanged = ImageViewVectorialChanged; 352 | } 353 | 354 | ROMPolygon = ImageView->AddNewObject(); 355 | 356 | TPoint LinePoints[4]; 357 | 358 | TIniFile *ini; 359 | ini = new TIniFile( ChangeFileExt( Application->ExeName, ".ini" ) ); 360 | LinePoints[0].x = ini->ReadInteger( "ROMPolygon", "0x", 100 ); 361 | LinePoints[0].y = ini->ReadInteger( "ROMPolygon", "0y", 100 ); 362 | LinePoints[1].x = ini->ReadInteger( "ROMPolygon", "1x", 200 ); 363 | LinePoints[1].y = ini->ReadInteger( "ROMPolygon", "1y", 100 ); 364 | LinePoints[2].x = ini->ReadInteger( "ROMPolygon", "2x", 200 ); 365 | LinePoints[2].y = ini->ReadInteger( "ROMPolygon", "2y", 200 ); 366 | LinePoints[3].x = ini->ReadInteger( "ROMPolygon", "3x", 100 ); 367 | LinePoints[3].y = ini->ReadInteger( "ROMPolygon", "3y", 200 ); 368 | delete ini; 369 | 370 | if( ImageView->IEBitmap->Width > 10 ) 371 | { 372 | // check if LinePoints[0..3] fit within image boundaries 373 | for( i=0; i<4; i++ ) 374 | { 375 | if( LinePoints[i].x >= ImageView->IEBitmap->Width || LinePoints[i].y >= ImageView->IEBitmap->Height ) 376 | break; 377 | } 378 | if( i<4 ) // at least one point is outside of image boundary 379 | { 380 | minx=LinePoints[0].x; 381 | miny=LinePoints[0].y; 382 | for( i=1; i<4; i++ ) 383 | { 384 | if( LinePoints[i].x < minx ) 385 | minx = LinePoints[i].x; 386 | if( LinePoints[i].y < miny ) 387 | miny = LinePoints[i].y; 388 | } 389 | for( i=0; i<4; i++ ) 390 | { 391 | LinePoints[i].x -= (minx-10); // adjust ROMBox so it will fit within a small image 392 | LinePoints[i].y -= (miny-10); 393 | } 394 | 395 | LogForm->LogMemo->Lines->Add("WARNING: The Area Of Interest overlay was outside image boundaries."); 396 | LogForm->LogMemo->Lines->Add("The position of the AOI has been adjusted to be visible within the current image."); 397 | } 398 | } 399 | 400 | ImageView->ObjKind[ROMPolygon] = iekPOLYLINE; 401 | ImageView->ObjPenWidth[ROMPolygon] = 1; 402 | ImageView->ObjPenColor[ROMPolygon] = clBlue; 403 | ImageView->ObjStyle[ROMPolygon] = TIEVStyle()<ObjName[ROMPolygon] = "ROMPolygon"; 405 | ImageView->SetObjPolylinePoints(ROMPolygon,LinePoints,3); 406 | ImageView->ObjPolylineClosed[ROMPolygon] = true; 407 | 408 | 409 | ImageView->MouseInteractVt=TIEMouseInteractVt()<SelAllObjects(); 411 | 412 | ImageView->OnVectorialChanged = ImageViewVectorialChanged; 413 | 414 | 415 | LogForm->LogMemo->Lines->Add("Move or resize the area of interest so the box exactly lines up with the bits you want to extract."); 416 | LogForm->LogMemo->Lines->Add("Select \"Cursor -> Adjust box corners\" to drag box corners to adjust for rotation."); 417 | LogForm->LogMemo->Lines->Add("Ensure \"Bits across AOI\" and \"Bits up and down AOI\" are correct, then select \"Area Of Interest -> Analyze bits within AOI\"."); 418 | LogForm->LogMemo->Lines->Add(""); 419 | } 420 | //--------------------------------------------------------------------------- 421 | void __fastcall TImageForm::EditPolyline1Click(TObject *Sender) 422 | { 423 | if( EditPolyline1->Checked ) 424 | ImageView->MouseInteractVt=TIEMouseInteractVt()<MouseInteractVt=TIEMouseInteractVt()<Checked = !EditPolyline1->Checked; 429 | } 430 | //--------------------------------------------------------------------------- 431 | void __fastcall TImageForm::FillROMBox1Click(TObject *Sender) 432 | { 433 | TPoint TL,TR,BL,BR; 434 | bool UseRed,UseGreen,UseBlue; 435 | int BitsPerCol; 436 | int BitsPerRow; 437 | 438 | int BoxWidth; 439 | int BoxHeight; 440 | 441 | int Threshold0; 442 | int Threshold1; 443 | 444 | int MinBright1,MaxBright0; 445 | int BitAnalysisMethod; 446 | 447 | int Dot1Threshold; 448 | int Dot0Threshold; 449 | int RimWidth; 450 | int DotWidth; 451 | 452 | int PixelSumR; 453 | int PixelSumG; 454 | int PixelSumB; 455 | 456 | int AboveThresholdR; 457 | int AboveThresholdG; 458 | int AboveThresholdB; 459 | int BelowThresholdR; 460 | int BelowThresholdG; 461 | int BelowThresholdB; 462 | 463 | int PixelSumGray; 464 | int NumChannels; 465 | int NumRimPixels; 466 | int NumDotPixels; 467 | 468 | 469 | int FullColCount; // total # of cols including gap between bits 470 | int FullRowCount; 471 | int i,n; 472 | 473 | int NumInvalidBits; 474 | 475 | 476 | if( ImageView->IEBitmap->Width<1 || ImageView->IEBitmap->Height<1 ) 477 | { 478 | LogForm->LogMemo->Lines->Add("Cannot analyze bits without an image loaded."); 479 | LogForm->LogMemo->Lines->Add(""); 480 | return; 481 | } 482 | if( ROMPolygon < 0 ) 483 | { 484 | LogForm->LogMemo->Lines->Add("Cannot analyze bits when Area Of Interest overlay is not shown."); 485 | LogForm->LogMemo->Lines->Add(""); 486 | return; 487 | } 488 | 489 | 490 | LogForm->LogMemo->Lines->Add("Analyzing bits within Area of Interest ...."); 491 | 492 | 493 | BitsPerCol = ROMBitSettingsForm->BitsPerColEdit->Text.ToIntDef(64); 494 | BitsPerRow = ROMBitSettingsForm->BitsPerRowEdit->Text.ToIntDef(8); 495 | BoxWidth = ROMBitSettingsForm->BoxWidthEdit->Text.ToIntDef(5); 496 | BoxHeight = ROMBitSettingsForm->BoxHeightEdit->Text.ToIntDef(5); 497 | 498 | Threshold0 = ROMBitSettingsForm->Threshold0Edit->Text.ToIntDef(1500); 499 | Threshold1 = ROMBitSettingsForm->Threshold1Edit->Text.ToIntDef(1700); 500 | 501 | Dot1Threshold = ROMBitSettingsForm->Dot1ThresholdEdit->Text.ToIntDef(0); 502 | Dot0Threshold = ROMBitSettingsForm->Dot0ThresholdEdit->Text.ToIntDef(0); 503 | RimWidth = ROMBitSettingsForm->RimWidthEdit->Text.ToIntDef(1); 504 | DotWidth = ROMBitSettingsForm->DotWidthEdit->Text.ToIntDef(1); 505 | 506 | 507 | // BitRowOfs = ROMBitSettingsForm->BitRowOfsEdit->Text.ToIntDef(0); 508 | 509 | /* 510 | //settings for st19 511 | FullColCount = (Ceil(BitsPerCol/64.0)- 1 )*3 + BitsPerCol; 512 | if(FullColCountRedCheckBox->Checked; 525 | UseGreen = ROMBitSettingsForm->GreenCheckBox->Checked; 526 | UseBlue = ROMBitSettingsForm->BlueCheckBox->Checked; 527 | 528 | MinBright1 = ROMBitSettingsForm->MinBright1Edit->Text.ToIntDef(0); 529 | MaxBright0 = ROMBitSettingsForm->MaxBright0Edit->Text.ToIntDef(0); 530 | BitAnalysisMethod = ROMBitSettingsForm->BitAnalysisMethodRadioGroup->ItemIndex; 531 | 532 | XBoxesPatternLen=0; 533 | if( XBoxesPattern ) 534 | delete[] XBoxesPattern; 535 | XBoxesPattern=NULL; 536 | YBoxesPatternLen=0; 537 | if( YBoxesPattern ) 538 | delete[] YBoxesPattern; 539 | YBoxesPattern=NULL; 540 | 541 | XBoxesPatternLen = ROMBitSettingsForm->XBoxesToAnalyzeEdit->Text.Length(); 542 | if( XBoxesPatternLen > 0 ) 543 | { 544 | XBoxesPattern = new int[XBoxesPatternLen]; 545 | if( !XBoxesPattern ) 546 | { 547 | Application->MessageBoxA("Memory allocation error! aborting FillROMBox.","ERROR",MB_OK); 548 | return; 549 | } 550 | 551 | n = 0; 552 | for( i=0; iXBoxesToAnalyzeEdit->Text[1+i] ) 555 | { 556 | case '1': 557 | XBoxesPattern[n++] = 1; 558 | break; 559 | 560 | case '0': 561 | XBoxesPattern[n++] = 0; 562 | break; 563 | } 564 | } 565 | XBoxesPatternLen = n; 566 | } 567 | YBoxesPatternLen = ROMBitSettingsForm->YBoxesToAnalyzeEdit->Text.Length(); 568 | if( YBoxesPatternLen > 0 ) 569 | { 570 | YBoxesPattern = new int[YBoxesPatternLen]; 571 | if( !YBoxesPattern ) 572 | { 573 | Application->MessageBoxA("Memory allocation error! aborting FillROMBox.","ERROR",MB_OK); 574 | return; 575 | } 576 | 577 | n = 0; 578 | for( i=0; iYBoxesToAnalyzeEdit->Text[1+i] ) 581 | { 582 | case '1': 583 | YBoxesPattern[n++] = 1; 584 | break; 585 | 586 | case '0': 587 | YBoxesPattern[n++] = 0; 588 | break; 589 | } 590 | } 591 | YBoxesPatternLen = n; 592 | } 593 | 594 | 595 | TL = ImageView->ObjPolylinePoints[ROMPolygon][0]; 596 | TR = ImageView->ObjPolylinePoints[ROMPolygon][1]; 597 | BR = ImageView->ObjPolylinePoints[ROMPolygon][2]; 598 | BL = ImageView->ObjPolylinePoints[ROMPolygon][3]; 599 | 600 | 601 | NumROMBits = BitsPerRow * BitsPerCol; 602 | if(ROMBit) 603 | { 604 | delete[] ROMBit; 605 | ROMBit=NULL; 606 | } 607 | ROMBit = new struct _ROMBit[NumROMBits]; 608 | 609 | 610 | for( int i=ImageView->ObjectsCount-1; i; i-- ) 611 | { 612 | if( ImageView->ObjKind[i] != iekPOLYLINE ) 613 | ImageView->RemoveObject(i); 614 | } 615 | 616 | for( int RowCounter=0,RowCounterOfs=0; RowCounterObjKind[-1] = iekBOX; 643 | ImageView->ObjLeft[-1] = BitPos.x-BoxWidth/2; 644 | ImageView->ObjTop[-1] = BitPos.y-BoxHeight/2; 645 | ImageView->ObjHeight[-1] = BoxHeight; 646 | ImageView->ObjWidth[-1] = BoxWidth; 647 | ImageView->ObjPenColor[-1] = clRed; 648 | ImageView->ObjStyle[-1] = TIEVStyle()<ObjTransparency[-1] = 128; // set transparency to 50% 651 | 652 | // fill in this ROMBit[] 653 | // int ROMBitIdx = BitRowCounter*BitsPerCol+BitColCounter; 654 | ROMBit[ROMBitIdx].Box=ImageView->AddNewObject(); 655 | ROMBit[ROMBitIdx].Value=-1; 656 | ROMBit[ROMBitIdx].PixelSumG=0; 657 | ROMBit[ROMBitIdx].PixelSum.r=0; 658 | ROMBit[ROMBitIdx].PixelSum.g=0; 659 | ROMBit[ROMBitIdx].PixelSum.b=0; 660 | ROMBit[ROMBitIdx].Pos.x=ColCounter; 661 | ROMBit[ROMBitIdx].Pos.y=RowCounter; 662 | 663 | 664 | 665 | // calc pixelsums 666 | PixelSumR=0; 667 | PixelSumG=0; 668 | PixelSumB=0; 669 | 670 | AboveThresholdR=0; 671 | AboveThresholdG=0; 672 | AboveThresholdB=0; 673 | BelowThresholdR=0; 674 | BelowThresholdG=0; 675 | BelowThresholdB=0; 676 | 677 | for( int BoxRow=0; BoxRowIEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].r; 683 | if( UseGreen ) 684 | PixelSumG += ImageView->IEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].g; 685 | if( UseBlue ) 686 | PixelSumB += ImageView->IEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].b; 687 | } 688 | } 689 | 690 | if( UseRed ) 691 | ROMBit[ROMBitIdx].PixelSum.r = PixelSumR / (BoxHeight*BoxWidth); 692 | if( UseGreen ) 693 | ROMBit[ROMBitIdx].PixelSum.g = PixelSumG / (BoxHeight*BoxWidth); 694 | if( UseBlue ) 695 | ROMBit[ROMBitIdx].PixelSum.b = PixelSumB / (BoxHeight*BoxWidth); 696 | 697 | PixelSumGray=0; 698 | NumChannels=0; 699 | ROMBit[ROMBitIdx].PixelsAboveThreshold=0; 700 | ROMBit[ROMBitIdx].PixelsBelowThreshold=0; 701 | 702 | if( UseRed ) 703 | { 704 | PixelSumGray += ROMBit[ROMBitIdx].PixelSum.r; 705 | NumChannels++; 706 | } 707 | if( UseGreen ) 708 | { 709 | PixelSumGray += ROMBit[ROMBitIdx].PixelSum.g; 710 | NumChannels++; 711 | } 712 | if( UseBlue ) 713 | { 714 | PixelSumGray += ROMBit[ROMBitIdx].PixelSum.b; 715 | NumChannels++; 716 | } 717 | 718 | if( NumChannels ) 719 | { 720 | ROMBit[ROMBitIdx].PixelSumG = PixelSumGray / NumChannels; 721 | } 722 | else 723 | ROMBit[ROMBitIdx].PixelSumG = PixelSumGray; 724 | 725 | 726 | switch( BitAnalysisMethod ) 727 | { 728 | case 2: // dot finder 729 | 730 | ROMBit[ROMBitIdx].RimLevel = 0; 731 | ROMBit[ROMBitIdx].DotLevel = 0; 732 | NumRimPixels=0; 733 | NumDotPixels=0; 734 | for( int BoxRow=0; BoxRowIEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].r; 742 | if( UseGreen ) 743 | ROMBit[ROMBitIdx].RimLevel += ImageView->IEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].g; 744 | if( UseBlue ) 745 | ROMBit[ROMBitIdx].RimLevel += ImageView->IEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].b; 746 | NumRimPixels++; 747 | } 748 | 749 | if( BoxRow >= ((BoxHeight/2.0) - (DotWidth/2.0) + 0.5) && BoxRow <= ((BoxHeight/2.0) + (DotWidth/2.0) + 0.5) && BoxCol >= ((BoxWidth/2.0) - (DotWidth/2.0) + 0.5) && BoxCol <= ((BoxWidth/2.0) + (DotWidth/2.0) + 0.5) ) 750 | { 751 | if( UseRed ) 752 | ROMBit[ROMBitIdx].DotLevel += ImageView->IEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].r; 753 | if( UseGreen ) 754 | ROMBit[ROMBitIdx].DotLevel += ImageView->IEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].g; 755 | if( UseBlue ) 756 | ROMBit[ROMBitIdx].DotLevel += ImageView->IEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].b; 757 | NumDotPixels++; 758 | } 759 | } 760 | } 761 | 762 | NumChannels=0; 763 | 764 | if( UseRed ) 765 | NumChannels++; 766 | if( UseGreen ) 767 | NumChannels++; 768 | if( UseBlue ) 769 | NumChannels++; 770 | 771 | if( NumChannels ) 772 | { 773 | ROMBit[ROMBitIdx].RimLevel /= NumChannels; 774 | ROMBit[ROMBitIdx].DotLevel /= NumChannels; 775 | } 776 | if( NumRimPixels ) 777 | ROMBit[ROMBitIdx].RimLevel /= NumRimPixels; 778 | if( NumDotPixels ) 779 | ROMBit[ROMBitIdx].DotLevel /= NumDotPixels; 780 | 781 | if( ROMBit[ROMBitIdx].DotLevel - ROMBit[ROMBitIdx].RimLevel <= Dot0Threshold ) 782 | { 783 | ROMBit[ROMBitIdx].Value = 0; 784 | ImageView->ObjPenColor[ROMBit[ROMBitIdx].Box] = clBlue; 785 | } 786 | else if( ROMBit[ROMBitIdx].DotLevel - ROMBit[ROMBitIdx].RimLevel >= Dot1Threshold ) 787 | { 788 | ROMBit[ROMBitIdx].Value = 1; 789 | ImageView->ObjPenColor[ROMBit[ROMBitIdx].Box] = clYellow; 790 | } 791 | break; 792 | 793 | 794 | case 1: // # of bright pixels within bit-box 795 | // calc pixelsums 796 | PixelSumR=0; 797 | PixelSumG=0; 798 | PixelSumB=0; 799 | 800 | AboveThresholdR=0; 801 | AboveThresholdG=0; 802 | AboveThresholdB=0; 803 | BelowThresholdR=0; 804 | BelowThresholdG=0; 805 | BelowThresholdB=0; 806 | 807 | for( int BoxRow=0; BoxRowIEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].r >= Threshold1 ) 812 | AboveThresholdR++; 813 | if( UseGreen && ImageView->IEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].g >= Threshold1 ) 814 | AboveThresholdG++; 815 | if( UseBlue && ImageView->IEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].b >= Threshold1 ) 816 | AboveThresholdB++; 817 | if( UseRed && ImageView->IEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].r <= Threshold0 ) 818 | BelowThresholdR++; 819 | if( UseGreen && ImageView->IEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].g <= Threshold0 ) 820 | BelowThresholdG++; 821 | if( UseBlue && ImageView->IEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].b <= Threshold0 ) 822 | BelowThresholdB++; 823 | } 824 | } 825 | 826 | NumChannels=0; 827 | ROMBit[ROMBitIdx].PixelsAboveThreshold=0; 828 | ROMBit[ROMBitIdx].PixelsBelowThreshold=0; 829 | 830 | if( UseRed ) 831 | { 832 | ROMBit[ROMBitIdx].PixelsAboveThreshold += AboveThresholdR; 833 | ROMBit[ROMBitIdx].PixelsBelowThreshold += BelowThresholdR; 834 | NumChannels++; 835 | } 836 | if( UseGreen ) 837 | { 838 | ROMBit[ROMBitIdx].PixelsAboveThreshold += AboveThresholdG; 839 | ROMBit[ROMBitIdx].PixelsBelowThreshold += BelowThresholdG; 840 | NumChannels++; 841 | } 842 | if( UseBlue ) 843 | { 844 | ROMBit[ROMBitIdx].PixelsAboveThreshold += AboveThresholdB; 845 | ROMBit[ROMBitIdx].PixelsBelowThreshold += BelowThresholdB; 846 | NumChannels++; 847 | } 848 | 849 | if( NumChannels ) 850 | { 851 | ROMBit[ROMBitIdx].PixelsAboveThreshold /= NumChannels; 852 | ROMBit[ROMBitIdx].PixelsBelowThreshold /= NumChannels; 853 | } 854 | 855 | 856 | if( ROMBit[ROMBitIdx].PixelsAboveThreshold <= MaxBright0 ) 857 | { 858 | ROMBit[ROMBitIdx].Value = 0; 859 | ImageView->ObjPenColor[ROMBit[ROMBitIdx].Box] = clBlue; 860 | } 861 | else if( ROMBit[ROMBitIdx].PixelsAboveThreshold >= MinBright1 ) 862 | { 863 | ROMBit[ROMBitIdx].Value = 1; 864 | ImageView->ObjPenColor[ROMBit[ROMBitIdx].Box] = clYellow; 865 | } 866 | break; 867 | 868 | 869 | case 0: // avg. brightness within bit-box 870 | default: 871 | /* 872 | // calc pixelsums 873 | PixelSumR=0; 874 | PixelSumG=0; 875 | PixelSumB=0; 876 | 877 | AboveThresholdR=0; 878 | AboveThresholdG=0; 879 | AboveThresholdB=0; 880 | BelowThresholdR=0; 881 | BelowThresholdG=0; 882 | BelowThresholdB=0; 883 | 884 | for( int BoxRow=0; BoxRowIEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].r; 890 | if( UseGreen ) 891 | PixelSumG += ImageView->IEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].g; 892 | if( UseBlue ) 893 | PixelSumB += ImageView->IEBitmap->Pixels[ImageView->ObjLeft[-2]+BoxCol][ImageView->ObjTop[-2]+BoxRow].b; 894 | } 895 | } 896 | 897 | if( UseRed ) 898 | ROMBit[ROMBitIdx].PixelSum.r = PixelSumR / (BoxHeight*BoxWidth); 899 | if( UseGreen ) 900 | ROMBit[ROMBitIdx].PixelSum.g = PixelSumG / (BoxHeight*BoxWidth); 901 | if( UseBlue ) 902 | ROMBit[ROMBitIdx].PixelSum.b = PixelSumB / (BoxHeight*BoxWidth); 903 | 904 | PixelSumGray=0; 905 | NumChannels=0; 906 | ROMBit[ROMBitIdx].PixelsAboveThreshold=0; 907 | ROMBit[ROMBitIdx].PixelsBelowThreshold=0; 908 | 909 | if( UseRed ) 910 | { 911 | PixelSumGray += ROMBit[ROMBitIdx].PixelSum.r; 912 | NumChannels++; 913 | } 914 | if( UseGreen ) 915 | { 916 | PixelSumGray += ROMBit[ROMBitIdx].PixelSum.g; 917 | NumChannels++; 918 | } 919 | if( UseBlue ) 920 | { 921 | PixelSumGray += ROMBit[ROMBitIdx].PixelSum.b; 922 | NumChannels++; 923 | } 924 | 925 | if( NumChannels ) 926 | { 927 | ROMBit[ROMBitIdx].PixelSumG = PixelSumGray / NumChannels; 928 | } 929 | else 930 | ROMBit[ROMBitIdx].PixelSumG = PixelSumGray; 931 | */ 932 | 933 | 934 | if( ROMBit[ROMBitIdx].PixelSumG <= Threshold0 ) 935 | { 936 | ROMBit[ROMBitIdx].Value = 0; 937 | ImageView->ObjPenColor[ROMBit[ROMBitIdx].Box] = clBlue; 938 | } 939 | else if( ROMBit[ROMBitIdx].PixelSumG >= Threshold1 ) 940 | { 941 | ROMBit[ROMBitIdx].Value = 1; 942 | ImageView->ObjPenColor[ROMBit[ROMBitIdx].Box] = clYellow; 943 | } 944 | break; 945 | } 946 | } 947 | } 948 | 949 | 950 | FillBitView(); 951 | 952 | 953 | // scan through bits and check for any ? -- ask user if they want to save file as-is or if they will correct errors 954 | NumInvalidBits=0; 955 | for( i=0; iNumROMBits; i++ ) 956 | { 957 | if( ROMBit[i].Active == 0 ) 958 | continue; 959 | if( ROMBit[i].Value < 0 || ImageForm->ROMBit[i].Value > 1 ) 960 | NumInvalidBits++; 961 | } 962 | 963 | LogForm->LogMemo->Lines->Add("Area of Interest has been analyzed for bits."); 964 | LogForm->LogMemo->Lines->Add("'1' bits are yellow, '0' bits are blue, undetermined bits are red."); 965 | LogForm->LogMemo->Lines->Add("Click within the image area to give the image focus, then press '1' or '0' while mouse is hovering over bits to adjust them."); 966 | LogForm->LogMemo->Lines->Add("Use \"File -> Export bits to file...\" to save the bit pattern to disk."); 967 | if( NumInvalidBits ) 968 | { 969 | AnsiString TempStr; 970 | 971 | TempStr.sprintf( "WARNING - UNRECOGNIZED BITS! %d bits have not been identified as 1 or 0 - they are marked red.", NumInvalidBits); 972 | LogForm->LogMemo->Lines->Add( TempStr ); 973 | } 974 | LogForm->LogMemo->Lines->Add(""); 975 | 976 | } 977 | //--------------------------------------------------------------------------- 978 | void __fastcall TImageForm::Clearallobjects1Click(TObject *Sender) 979 | { 980 | ImageView->UnSelAllObjects(); 981 | 982 | NumROMBits = 0; 983 | if(ROMBit) 984 | { 985 | delete[] ROMBit; 986 | ROMBit=NULL; 987 | } 988 | 989 | for( int i=ImageView->ObjectsCount-1; i; i-- ) 990 | { 991 | if( ImageView->ObjKind[i] != iekPOLYLINE ) 992 | ImageView->RemoveObject(i); 993 | } 994 | 995 | if( ROMPolygon > -1 ) 996 | ImageView->AddSelObject(ROMPolygon); 997 | } 998 | //--------------------------------------------------------------------------- 999 | void __fastcall TImageForm::Transparency1Click(TObject *Sender) 1000 | { 1001 | // if(ROMPolygon>-1) 1002 | // ImageView->ObjTransparency[ROMPolygon] = 255; 1003 | for( int counter=0; counter< NumROMBits; counter++) 1004 | { 1005 | if( !ROMBit[counter].Active ) 1006 | continue; 1007 | 1008 | ImageView->ObjTransparency[ROMBit[counter].Box] = 255; 1009 | } 1010 | } 1011 | //--------------------------------------------------------------------------- 1012 | void __fastcall TImageForm::Transparency501Click(TObject *Sender) 1013 | { 1014 | // if(ROMPolygon>-1) 1015 | // ImageView->ObjTransparency[ROMPolygon] = 128; 1016 | for( int counter=0; counter< NumROMBits; counter++) 1017 | { 1018 | if( !ROMBit[counter].Active ) 1019 | continue; 1020 | 1021 | ImageView->ObjTransparency[ROMBit[counter].Box] = 128; 1022 | } 1023 | } 1024 | //--------------------------------------------------------------------------- 1025 | void __fastcall TImageForm::Transparency801Click(TObject *Sender) 1026 | { 1027 | // if(ROMPolygon>-1) 1028 | // ImageView->ObjTransparency[ROMPolygon] = 255.0*0.20; 1029 | for( int counter=0; counter< NumROMBits; counter++) 1030 | { 1031 | if( !ROMBit[counter].Active ) 1032 | continue; 1033 | 1034 | ImageView->ObjTransparency[ROMBit[counter].Box] = 255.0*0.20; 1035 | } 1036 | } 1037 | //--------------------------------------------------------------------------- 1038 | void __fastcall TImageForm::ImageViewMouseMove(TObject *Sender, 1039 | TShiftState Shift, int X, int Y) 1040 | { 1041 | double ObjectDistance; 1042 | int FoundObject; 1043 | int FoundBitBox; 1044 | 1045 | FoundObject = ImageView->FindObjectAt(X, Y, ObjectDistance); 1046 | 1047 | if( ObjectDistance < 5 ) 1048 | { 1049 | // ImageView->ObjPenColor[FoundObject] = clGreen; 1050 | 1051 | for( FoundBitBox=0; FoundBitBoxBitBoxIdxLabel->Caption = FoundBitBox; 1059 | ROMBitSettingsForm->PixelSumLabel->Caption = ROMBit[FoundBitBox].PixelSumG; 1060 | ROMBitSettingsForm->PixelsAboveThresholdLabel->Caption = ROMBit[FoundBitBox].PixelsAboveThreshold; 1061 | ROMBitSettingsForm->PixelsBelowThresholdLabel->Caption = ROMBit[FoundBitBox].PixelsBelowThreshold; 1062 | ROMBitSettingsForm->DotLevelLabel->Caption = ROMBit[FoundBitBox].DotLevel; 1063 | ROMBitSettingsForm->RimLevelLabel->Caption = ROMBit[FoundBitBox].RimLevel; 1064 | } 1065 | } 1066 | } 1067 | //--------------------------------------------------------------------------- 1068 | void __fastcall TImageForm::Processing1Click(TObject *Sender) 1069 | { 1070 | ImageView->Proc->DoPreviews(); 1071 | } 1072 | //--------------------------------------------------------------------------- 1073 | void __fastcall TImageForm::Undo1Click(TObject *Sender) 1074 | { 1075 | ImageView->Proc->Undo(true); 1076 | } 1077 | //--------------------------------------------------------------------------- 1078 | void __fastcall TImageForm::Redo1Click(TObject *Sender) 1079 | { 1080 | ImageView->Proc->Redo(); 1081 | } 1082 | //--------------------------------------------------------------------------- 1083 | void __fastcall TImageForm::FillBitView(void) 1084 | { 1085 | int BitsPerCol; 1086 | int BitsPerRow; 1087 | int ActiveBitsPerCol; 1088 | int ActiveBitsPerRow; 1089 | 1090 | BitsPerCol = ROMBitSettingsForm->BitsPerColEdit->Text.ToIntDef(64); 1091 | BitsPerRow = ROMBitSettingsForm->BitsPerRowEdit->Text.ToIntDef(8); 1092 | 1093 | 1094 | bool UseRed,UseGreen,UseBlue; 1095 | 1096 | UseRed = ROMBitSettingsForm->RedCheckBox->Checked; 1097 | UseGreen = ROMBitSettingsForm->GreenCheckBox->Checked; 1098 | UseBlue = ROMBitSettingsForm->BlueCheckBox->Checked; 1099 | 1100 | 1101 | 1102 | ActiveBitsPerCol=0; 1103 | for( int BitBoxCounter=0; BitBoxCounter< BitsPerCol; BitBoxCounter++ ) 1104 | { 1105 | if( XBoxesPatternLen && !XBoxesPattern[ BitBoxCounter % XBoxesPatternLen ] ) 1106 | continue; 1107 | 1108 | ActiveBitsPerCol++; 1109 | } 1110 | 1111 | ActiveBitsPerRow=0; 1112 | for( int BitBoxCounter=0; BitBoxCounter< BitsPerRow; BitBoxCounter++ ) 1113 | { 1114 | if( YBoxesPatternLen && !YBoxesPattern[ BitBoxCounter % YBoxesPatternLen ] ) 1115 | continue; 1116 | 1117 | ActiveBitsPerRow++; 1118 | } 1119 | 1120 | 1121 | ROMBitSettingsForm->BitView->IEBitmap->Allocate(ActiveBitsPerCol,ActiveBitsPerRow,ie24RGB); 1122 | ROMBitSettingsForm->BitView->IEBitmap->Fill(clBlack); 1123 | 1124 | 1125 | for( int RowCounter=0, ActiveBitsPerRow=0; RowCounterBitView->IEBitmap->PPixels_ie24RGB[ActiveBitsPerCol][ActiveBitsPerRow]->r = ROMBit[ROMBitIdx].PixelSum.r; 1139 | else 1140 | ROMBitSettingsForm->BitView->IEBitmap->PPixels_ie24RGB[ActiveBitsPerCol][ActiveBitsPerRow]->r = ROMBit[ROMBitIdx].PixelSumG; 1141 | 1142 | if(UseGreen) 1143 | ROMBitSettingsForm->BitView->IEBitmap->PPixels_ie24RGB[ActiveBitsPerCol][ActiveBitsPerRow]->g = ROMBit[ROMBitIdx].PixelSum.g; 1144 | else 1145 | ROMBitSettingsForm->BitView->IEBitmap->PPixels_ie24RGB[ActiveBitsPerCol][ActiveBitsPerRow]->g = ROMBit[ROMBitIdx].PixelSumG; 1146 | 1147 | if(UseBlue) 1148 | ROMBitSettingsForm->BitView->IEBitmap->PPixels_ie24RGB[ActiveBitsPerCol][ActiveBitsPerRow]->b = ROMBit[ROMBitIdx].PixelSum.b; 1149 | else 1150 | ROMBitSettingsForm->BitView->IEBitmap->PPixels_ie24RGB[ActiveBitsPerCol][ActiveBitsPerRow]->b = ROMBit[ROMBitIdx].PixelSumG; 1151 | 1152 | ActiveBitsPerCol++; 1153 | } 1154 | ActiveBitsPerRow++; 1155 | } 1156 | 1157 | /* 1158 | int RowCounter=0; //( BitBoxCounter / BitsPerCol); 1159 | int ColCounter=0; //(BitBoxCounter % BitsPerCol ); 1160 | int NewRow=0; 1161 | for( int BitBoxCounter=0; BitBoxCounter< NumROMBits; BitBoxCounter++ ) 1162 | { 1163 | if(BitBoxCounter && !(BitBoxCounter%BitsPerCol)) 1164 | NewRow = 1; 1165 | 1166 | if( !ROMBit[BitBoxCounter].Active ) 1167 | continue; 1168 | 1169 | ColCounter++; 1170 | 1171 | if(NewRow) 1172 | { 1173 | ColCounter=0; 1174 | RowCounter++; 1175 | NewRow=0; 1176 | } 1177 | 1178 | if(UseRed) 1179 | ROMBitSettingsForm->BitView->IEBitmap->PPixels_ie24RGB[ColCounter][RowCounter]->r = ROMBit[BitBoxCounter].PixelSum.r; 1180 | else 1181 | ROMBitSettingsForm->BitView->IEBitmap->PPixels_ie24RGB[ColCounter][RowCounter]->r = ROMBit[BitBoxCounter].PixelSumG; 1182 | 1183 | if(UseGreen) 1184 | ROMBitSettingsForm->BitView->IEBitmap->PPixels_ie24RGB[ColCounter][RowCounter]->g = ROMBit[BitBoxCounter].PixelSum.g; 1185 | else 1186 | ROMBitSettingsForm->BitView->IEBitmap->PPixels_ie24RGB[ColCounter][RowCounter]->g = ROMBit[BitBoxCounter].PixelSumG; 1187 | 1188 | if(UseBlue) 1189 | ROMBitSettingsForm->BitView->IEBitmap->PPixels_ie24RGB[ColCounter][RowCounter]->b = ROMBit[BitBoxCounter].PixelSum.b; 1190 | else 1191 | ROMBitSettingsForm->BitView->IEBitmap->PPixels_ie24RGB[ColCounter][RowCounter]->b = ROMBit[BitBoxCounter].PixelSumG; 1192 | } 1193 | */ 1194 | ROMBitSettingsForm->BitView->Update(); 1195 | ROMBitSettingsForm->HistogramBox->Update(); 1196 | ROMBitSettingsForm->Update(); 1197 | } 1198 | //--------------------------------------------------------------------------- 1199 | void __fastcall TImageForm::ImageViewDblClick(TObject *Sender) 1200 | { 1201 | TPoint CursorPos; 1202 | 1203 | CursorPos = Mouse->CursorPos; 1204 | 1205 | CursorPos = ImageView->ScreenToClient( CursorPos ); 1206 | 1207 | double ObjectDistance; 1208 | int FoundObject; 1209 | int FoundBitBox; 1210 | 1211 | FoundObject = ImageView->FindObjectAt(CursorPos.x, CursorPos.y, ObjectDistance); 1212 | 1213 | if( ObjectDistance < 5 ) 1214 | { 1215 | // ImageView->ObjPenColor[FoundObject] = clGreen; 1216 | 1217 | for( FoundBitBox=0; FoundBitBoxBitBoxIdxLabel->Caption = FoundBitBox; 1225 | // ROMBitSettingsForm->PixelSumLabel->Caption = ROMBit[FoundBitBox].PixelSumG; 1226 | ROMBit[FoundBitBox].Value++; 1227 | if(ROMBit[FoundBitBox].Value>1) 1228 | ROMBit[FoundBitBox].Value=-1; 1229 | switch( ROMBit[FoundBitBox].Value ) 1230 | { 1231 | case 0: 1232 | ImageView->ObjPenColor[ROMBit[FoundBitBox].Box] = clBlue; 1233 | break; 1234 | 1235 | case 1: 1236 | ImageView->ObjPenColor[ROMBit[FoundBitBox].Box] = clYellow; 1237 | break; 1238 | 1239 | case -1: 1240 | ImageView->ObjPenColor[ROMBit[FoundBitBox].Box] = clRed; 1241 | break; 1242 | } 1243 | ImageView->Update(); 1244 | } 1245 | } 1246 | } 1247 | //--------------------------------------------------------------------------- 1248 | void __fastcall TImageForm::ImageViewKeyPress(TObject *Sender, char &Key) 1249 | { 1250 | TPoint CursorPos; 1251 | 1252 | CursorPos = Mouse->CursorPos; 1253 | 1254 | CursorPos = ImageView->ScreenToClient( CursorPos ); 1255 | 1256 | double ObjectDistance; 1257 | int FoundObject; 1258 | int FoundBitBox; 1259 | 1260 | FoundObject = ImageView->FindObjectAt(CursorPos.x, CursorPos.y, ObjectDistance); 1261 | 1262 | if( ObjectDistance < 5 ) 1263 | { 1264 | // ImageView->ObjPenColor[FoundObject] = clGreen; 1265 | 1266 | for( FoundBitBox=0; FoundBitBoxObjPenColor[ROMBit[FoundBitBox].Box] = clBlue; 1278 | break; 1279 | 1280 | case '1': 1281 | ROMBit[FoundBitBox].Value=1; 1282 | ImageView->ObjPenColor[ROMBit[FoundBitBox].Box] = clYellow; 1283 | break; 1284 | 1285 | case '.': 1286 | ROMBit[FoundBitBox].Value=-1; 1287 | ImageView->ObjPenColor[ROMBit[FoundBitBox].Box] = clRed; 1288 | break; 1289 | } 1290 | ImageView->Update(); 1291 | } 1292 | } 1293 | } 1294 | //--------------------------------------------------------------------------- 1295 | void __fastcall TImageForm::ImageViewVectorialChanged(TObject *Sender) 1296 | { 1297 | if( ROMPolygon < 0 ) 1298 | return; 1299 | if( ImageView->ObjPolylinePointsCount[ROMPolygon] > 0 && ImageView->ObjPolylinePointsCount[ROMPolygon] != 4 ) 1300 | { 1301 | TPoint LinePoints[4]; 1302 | int i; 1303 | 1304 | // ideally we would remove the point that is closest to another point - that is probably the new one accidentally added? 1305 | // really most likely candidate is the one that is in line between two others - but need to calculate line path & distance from it to find that 1306 | for( i=0; i<4; i++ ) 1307 | { 1308 | LinePoints[i].x = ImageView->ObjPolylinePoints[ROMPolygon][i].x; 1309 | LinePoints[i].y = ImageView->ObjPolylinePoints[ROMPolygon][i].y; 1310 | } 1311 | /* 1312 | TIniFile *ini; 1313 | ini = new TIniFile( ChangeFileExt( Application->ExeName, ".ini" ) ); 1314 | LinePoints[0].x = ini->ReadInteger( "ROMPolygon", "0x", 100 ); 1315 | LinePoints[0].y = ini->ReadInteger( "ROMPolygon", "0y", 100 ); 1316 | LinePoints[1].x = ini->ReadInteger( "ROMPolygon", "1x", 200 ); 1317 | LinePoints[1].y = ini->ReadInteger( "ROMPolygon", "1y", 100 ); 1318 | LinePoints[2].x = ini->ReadInteger( "ROMPolygon", "2x", 200 ); 1319 | LinePoints[2].y = ini->ReadInteger( "ROMPolygon", "2y", 200 ); 1320 | LinePoints[3].x = ini->ReadInteger( "ROMPolygon", "3x", 100 ); 1321 | LinePoints[3].y = ini->ReadInteger( "ROMPolygon", "3y", 200 ); 1322 | delete ini; 1323 | */ 1324 | ImageView->ObjKind[ROMPolygon] = iekPOLYLINE; 1325 | ImageView->ObjPenWidth[ROMPolygon] = 1; 1326 | ImageView->ObjPenColor[ROMPolygon] = clBlue; 1327 | ImageView->ObjStyle[ROMPolygon] = TIEVStyle()<ObjName[ROMPolygon] = "ROMPolygon"; 1329 | ImageView->SetObjPolylinePoints(ROMPolygon,LinePoints,3); 1330 | ImageView->ObjPolylineClosed[ROMPolygon] = true; 1331 | } 1332 | } 1333 | //--------------------------------------------------------------------------- 1334 | void __fastcall TImageForm::Fittowindow1Click(TObject *Sender) 1335 | { 1336 | ImageView->Fit(); 1337 | UpdateCaption(); 1338 | } 1339 | //--------------------------------------------------------------------------- 1340 | void __fastcall TImageForm::ZoomIn1Click(TObject *Sender) 1341 | { 1342 | ImageView->Zoom *= 1.05; 1343 | UpdateCaption(); 1344 | } 1345 | //--------------------------------------------------------------------------- 1346 | void __fastcall TImageForm::ZoomOut1Click(TObject *Sender) 1347 | { 1348 | ImageView->Zoom /= 1.05; 1349 | UpdateCaption(); 1350 | } 1351 | //--------------------------------------------------------------------------- 1352 | void __fastcall TImageForm::ResetROMBox1Click(TObject *Sender) 1353 | { 1354 | NumROMBits = 0; 1355 | if(ROMBit) 1356 | { 1357 | delete[] ROMBit; 1358 | ROMBit=NULL; 1359 | } 1360 | 1361 | ImageView->OnVectorialChanged = NULL; 1362 | ImageView->UnSelAllObjects(); 1363 | ImageView->RemoveAllObjects(); 1364 | 1365 | ROMPolygon = ImageView->AddNewObject(); 1366 | 1367 | TPoint LinePoints[4]; 1368 | LinePoints[0].x = 100; 1369 | LinePoints[0].y = 100; 1370 | LinePoints[1].x = 200; 1371 | LinePoints[1].y = 100; 1372 | LinePoints[2].x = 200; 1373 | LinePoints[2].y = 200; 1374 | LinePoints[3].x = 100; 1375 | LinePoints[3].y = 200; 1376 | 1377 | ImageView->ObjKind[ROMPolygon] = iekPOLYLINE; 1378 | ImageView->ObjPenWidth[ROMPolygon] = 1; 1379 | ImageView->ObjPenColor[ROMPolygon] = clBlue; 1380 | ImageView->ObjStyle[ROMPolygon] = TIEVStyle()<ObjName[ROMPolygon] = "ROMPolygon"; 1382 | ImageView->SetObjPolylinePoints(ROMPolygon,LinePoints,3); 1383 | ImageView->ObjPolylineClosed[ROMPolygon] = true; 1384 | 1385 | ImageView->MouseInteractVt=TIEMouseInteractVt()<SelAllObjects(); 1387 | 1388 | ImageView->OnVectorialChanged = ImageViewVectorialChanged; 1389 | } 1390 | //--------------------------------------------------------------------------- 1391 | void __fastcall TImageForm::Exportbits1Click(TObject *Sender) 1392 | { 1393 | FILE *BitTxtFile; 1394 | int BitCounter; 1395 | 1396 | if( ImageForm->NumROMBits < 1 ) 1397 | { 1398 | Application->MessageBoxA("You must first define the Area Of Interest and then Analyze bits within AOI before you can export the bits.", "No bits to export", MB_OK ); 1399 | return; // nothing to save 1400 | } 1401 | 1402 | // scan through bits and check for any ? -- ask user if they want to save file as-is or if they will correct errors 1403 | for( BitCounter=0; BitCounterNumROMBits; BitCounter++ ) 1404 | { 1405 | if( ImageForm->ROMBit[BitCounter].Active == 0 ) 1406 | continue; 1407 | if( ImageForm->ROMBit[BitCounter].Value < 0 || ImageForm->ROMBit[BitCounter].Value > 1 ) 1408 | break; 1409 | } 1410 | if( BitCounterNumROMBits ) 1411 | { 1412 | if( Application->MessageBoxA( "Some bits have not been identified as 1 or 0.\nThey will appear as '?' in the output file.\n\nDo you want to export the bits anyway?", "WARNING - Some bits not recognized!", MB_YESNO ) != IDYES ) 1413 | return; 1414 | } 1415 | 1416 | 1417 | if( WorkingDir.Length() && ROMBitSaveDialog->InitialDir != WorkingDir ) 1418 | { 1419 | ROMBitSaveDialog->InitialDir = WorkingDir; 1420 | ROMBitSaveDialog->FileName = ""; 1421 | } 1422 | 1423 | if( ROMBitSaveDialog->Execute() != mrOk ) 1424 | return; 1425 | 1426 | WorkingDir = ROMBitSaveDialog->FileName.SubString(1, ROMBitSaveDialog->FileName.LastDelimiter( ":\\" ) ); 1427 | 1428 | // open ROMBitSaveDialog->FileName 1429 | BitTxtFile = fopen( ROMBitSaveDialog->FileName.c_str(), "wt" ); 1430 | if( !BitTxtFile ) 1431 | { 1432 | Application->MessageBox("Error opening file for output.","Error",MB_OK); 1433 | return; 1434 | } 1435 | 1436 | int BitsPerCol=64; 1437 | // int BitsPerRow=8; 1438 | 1439 | BitsPerCol = ROMBitSettingsForm->BitsPerColEdit->Text.ToIntDef(64); 1440 | // BitsPerRow = ROMBitSettingsForm->BitsPerRowEdit->Text.ToIntDef(8); 1441 | 1442 | for( BitCounter=0; BitCounterNumROMBits; BitCounter++ ) 1443 | { 1444 | int RowCounter= ( BitCounter / BitsPerCol); 1445 | int ColCounter= (BitCounter % BitsPerCol ); 1446 | 1447 | if( (!ColCounter) && RowCounter ) 1448 | fprintf( BitTxtFile, "\n" ); // newline 1449 | 1450 | //output " " between columns 1451 | if( !ROMBit[BitCounter].Active ) 1452 | { 1453 | fprintf( BitTxtFile, " " ); 1454 | continue; 1455 | } 1456 | 1457 | // if( ColCounter==32 ) 1458 | // fprintf( BitTxtFile, " " ); // separator between columns every 32 bits 1459 | 1460 | //output bit 1461 | switch( ImageForm->ROMBit[BitCounter].Value ) 1462 | { 1463 | case 0: 1464 | fputc( '0', BitTxtFile ); 1465 | break; 1466 | 1467 | case 1: 1468 | fputc( '1', BitTxtFile ); 1469 | break; 1470 | 1471 | case -1: 1472 | default: 1473 | fputc( '?', BitTxtFile ); 1474 | break; 1475 | } 1476 | } 1477 | 1478 | fprintf( BitTxtFile, "\n" ); 1479 | 1480 | fclose( BitTxtFile ); 1481 | } 1482 | //--------------------------------------------------------------------------- 1483 | void __fastcall TImageForm::ImageViewObjectClick(TObject *Sender, int hobj) 1484 | { 1485 | if( ROMPolygon >= 0 ) 1486 | { 1487 | if( ImageView->SelObjectsCount != 1 || ImageView->SelObjects[0] != ROMPolygon ) 1488 | { 1489 | ImageView->UnSelAllObjects(); 1490 | ImageView->AddSelObject(ROMPolygon); 1491 | } 1492 | } 1493 | } 1494 | //--------------------------------------------------------------------------- 1495 | void __fastcall TImageForm::Loadsettings1Click(TObject *Sender) 1496 | { 1497 | TIniFile *SettingsIni; 1498 | 1499 | 1500 | if( WorkingDir.Length() && OpenSettingsDialog->InitialDir != WorkingDir ) 1501 | { 1502 | OpenSettingsDialog->InitialDir = WorkingDir; 1503 | OpenSettingsDialog->FileName = ""; 1504 | } 1505 | 1506 | if( OpenSettingsDialog->Execute() != mrOk ) 1507 | return; 1508 | 1509 | WorkingDir = OpenSettingsDialog->FileName.SubString(1, OpenSettingsDialog->FileName.LastDelimiter( ":\\" ) ); 1510 | 1511 | LoadSettings( OpenSettingsDialog->FileName ); 1512 | SaveSettings( ChangeFileExt( Application->ExeName, ".ini" ) ); 1513 | 1514 | if( PreviousFilename.Length() ) 1515 | LogForm->LogMemo->Lines->Add( "Loaded bit extraction settings for "+PreviousFilename ); 1516 | else 1517 | LogForm->LogMemo->Lines->Add( "Loaded bit extraction settings from file." ); 1518 | LogForm->LogMemo->Lines->Add( "" ); 1519 | 1520 | ShowROMBox1Click(NULL); 1521 | 1522 | return; 1523 | } 1524 | //--------------------------------------------------------------------------- 1525 | void __fastcall TImageForm::LoadSettings( AnsiString IniFilename ) 1526 | { 1527 | TPoint LinePoints[4]; 1528 | TIniFile *SettingsIni; 1529 | 1530 | 1531 | SettingsIni = new TIniFile( IniFilename ); 1532 | LinePoints[0].x = SettingsIni->ReadInteger( "ROMPolygon", "0x", 100 ); 1533 | LinePoints[0].y = SettingsIni->ReadInteger( "ROMPolygon", "0y", 100 ); 1534 | LinePoints[1].x = SettingsIni->ReadInteger( "ROMPolygon", "1x", 200 ); 1535 | LinePoints[1].y = SettingsIni->ReadInteger( "ROMPolygon", "1y", 100 ); 1536 | LinePoints[2].x = SettingsIni->ReadInteger( "ROMPolygon", "2x", 200 ); 1537 | LinePoints[2].y = SettingsIni->ReadInteger( "ROMPolygon", "2y", 200 ); 1538 | LinePoints[3].x = SettingsIni->ReadInteger( "ROMPolygon", "3x", 100 ); 1539 | LinePoints[3].y = SettingsIni->ReadInteger( "ROMPolygon", "3y", 200 ); 1540 | 1541 | ROMBitSettingsForm->BitsPerColEdit->Text = SettingsIni->ReadInteger( "BitSettings", "BitColumns", 16 ); 1542 | ROMBitSettingsForm->BitsPerRowEdit->Text = SettingsIni->ReadInteger( "BitSettings", "BitRows", 16 ); 1543 | ROMBitSettingsForm->BoxWidthEdit->Text = SettingsIni->ReadInteger( "BitSettings", "BoxWidth", 5 ); 1544 | ROMBitSettingsForm->BoxHeightEdit->Text = SettingsIni->ReadInteger( "BitSettings", "BoxHeight", 5 ); 1545 | ROMBitSettingsForm->Threshold0Edit->Text = SettingsIni->ReadInteger( "BitSettings", "Threshold0", 64 ); 1546 | ROMBitSettingsForm->Threshold1Edit->Text = SettingsIni->ReadInteger( "BitSettings", "Threshold1", 96 ); 1547 | ROMBitSettingsForm->MinBright1Edit->Text = SettingsIni->ReadInteger( "BitSettings", "MinBright1", 20 ); 1548 | ROMBitSettingsForm->MaxBright0Edit->Text = SettingsIni->ReadInteger( "BitSettings", "MaxBright0", 5 ); 1549 | ROMBitSettingsForm->BitAnalysisMethodRadioGroup->ItemIndex = SettingsIni->ReadInteger( "BitSettings", "BitAnalysisMethod", 0 ); 1550 | ROMBitSettingsForm->RedCheckBox->Checked = SettingsIni->ReadInteger( "BitSettings", "UseR", 1 ); 1551 | ROMBitSettingsForm->GreenCheckBox->Checked = SettingsIni->ReadInteger( "BitSettings", "UseG", 1 ); 1552 | ROMBitSettingsForm->BlueCheckBox->Checked = SettingsIni->ReadInteger( "BitSettings", "UseB", 1 ); 1553 | ROMBitSettingsForm->Dot1ThresholdEdit->Text = SettingsIni->ReadInteger( "BitSettings", "Dot1Threshold", 0 ); 1554 | ROMBitSettingsForm->Dot0ThresholdEdit->Text = SettingsIni->ReadInteger( "BitSettings", "Dot0Threshold", 0 ); 1555 | ROMBitSettingsForm->RimWidthEdit->Text = SettingsIni->ReadInteger( "BitSettings", "RimWidth", 1 ); 1556 | ROMBitSettingsForm->DotWidthEdit->Text = SettingsIni->ReadInteger( "BitSettings", "DotWidth", 1 ); 1557 | ROMBitSettingsForm->XBoxesToAnalyzeEdit->Text = SettingsIni->ReadString( "BitSettings", "XBoxesToAnalyze", "" ); 1558 | ROMBitSettingsForm->YBoxesToAnalyzeEdit->Text = SettingsIni->ReadString( "BitSettings", "YBoxesToAnalyze", "" ); 1559 | 1560 | PreviousFilename = SettingsIni->ReadString( "Image", "Filename", "" ); 1561 | 1562 | delete SettingsIni; 1563 | 1564 | SettingsIni = new TIniFile( ChangeFileExt( Application->ExeName, ".ini" ) ); 1565 | SettingsIni->WriteInteger( "ROMPolygon", "0x", LinePoints[0].x ); 1566 | SettingsIni->WriteInteger( "ROMPolygon", "0y", LinePoints[0].y ); 1567 | SettingsIni->WriteInteger( "ROMPolygon", "1x", LinePoints[1].x ); 1568 | SettingsIni->WriteInteger( "ROMPolygon", "1y", LinePoints[1].y ); 1569 | SettingsIni->WriteInteger( "ROMPolygon", "2x", LinePoints[2].x ); 1570 | SettingsIni->WriteInteger( "ROMPolygon", "2y", LinePoints[2].y ); 1571 | SettingsIni->WriteInteger( "ROMPolygon", "3x", LinePoints[3].x ); 1572 | SettingsIni->WriteInteger( "ROMPolygon", "3y", LinePoints[3].y ); 1573 | delete SettingsIni; 1574 | 1575 | 1576 | return; 1577 | } 1578 | //--------------------------------------------------------------------------- 1579 | void __fastcall TImageForm::Savesettings1Click(TObject *Sender) 1580 | { 1581 | if( WorkingDir.Length() && SaveSettingsDialog->InitialDir != WorkingDir ) 1582 | { 1583 | SaveSettingsDialog->InitialDir = WorkingDir; 1584 | SaveSettingsDialog->FileName = ""; 1585 | } 1586 | 1587 | if( SaveSettingsDialog->Execute() != mrOk ) 1588 | return; 1589 | 1590 | WorkingDir = SaveSettingsDialog->FileName.SubString(1, SaveSettingsDialog->FileName.LastDelimiter( ":\\" ) ); 1591 | 1592 | SaveSettings(SaveSettingsDialog->FileName); 1593 | 1594 | return; 1595 | } 1596 | //--------------------------------------------------------------------------- 1597 | void __fastcall TImageForm::SaveSettings(AnsiString IniFilename) 1598 | { 1599 | TIniFile *SettingsIni; 1600 | TPoint LinePoints[4]; 1601 | int BitsPerCol; 1602 | int BitsPerRow; 1603 | int BoxWidth; 1604 | int BoxHeight; 1605 | int Threshold0; 1606 | int Threshold1; 1607 | 1608 | 1609 | if( ROMPolygon > -1 ) 1610 | { 1611 | LinePoints[0].x = ImageView->ObjPolylinePoints[ROMPolygon][0].x; 1612 | LinePoints[0].y = ImageView->ObjPolylinePoints[ROMPolygon][0].y; 1613 | LinePoints[1].x = ImageView->ObjPolylinePoints[ROMPolygon][1].x; 1614 | LinePoints[1].y = ImageView->ObjPolylinePoints[ROMPolygon][1].y; 1615 | LinePoints[2].x = ImageView->ObjPolylinePoints[ROMPolygon][2].x; 1616 | LinePoints[2].y = ImageView->ObjPolylinePoints[ROMPolygon][2].y; 1617 | LinePoints[3].x = ImageView->ObjPolylinePoints[ROMPolygon][3].x; 1618 | LinePoints[3].y = ImageView->ObjPolylinePoints[ROMPolygon][3].y; 1619 | } 1620 | else 1621 | { 1622 | SettingsIni = new TIniFile( ChangeFileExt( Application->ExeName, ".ini" ) ); 1623 | LinePoints[0].x = SettingsIni->ReadInteger( "ROMPolygon", "0x", 100 ); 1624 | LinePoints[0].y = SettingsIni->ReadInteger( "ROMPolygon", "0y", 100 ); 1625 | LinePoints[1].x = SettingsIni->ReadInteger( "ROMPolygon", "1x", 200 ); 1626 | LinePoints[1].y = SettingsIni->ReadInteger( "ROMPolygon", "1y", 100 ); 1627 | LinePoints[2].x = SettingsIni->ReadInteger( "ROMPolygon", "2x", 200 ); 1628 | LinePoints[2].y = SettingsIni->ReadInteger( "ROMPolygon", "2y", 200 ); 1629 | LinePoints[3].x = SettingsIni->ReadInteger( "ROMPolygon", "3x", 100 ); 1630 | LinePoints[3].y = SettingsIni->ReadInteger( "ROMPolygon", "3y", 200 ); 1631 | delete SettingsIni; 1632 | } 1633 | 1634 | SettingsIni = new TIniFile( IniFilename ); 1635 | SettingsIni->WriteInteger( "ROMPolygon", "0x", LinePoints[0].x ); 1636 | SettingsIni->WriteInteger( "ROMPolygon", "0y", LinePoints[0].y ); 1637 | SettingsIni->WriteInteger( "ROMPolygon", "1x", LinePoints[1].x ); 1638 | SettingsIni->WriteInteger( "ROMPolygon", "1y", LinePoints[1].y ); 1639 | SettingsIni->WriteInteger( "ROMPolygon", "2x", LinePoints[2].x ); 1640 | SettingsIni->WriteInteger( "ROMPolygon", "2y", LinePoints[2].y ); 1641 | SettingsIni->WriteInteger( "ROMPolygon", "3x", LinePoints[3].x ); 1642 | SettingsIni->WriteInteger( "ROMPolygon", "3y", LinePoints[3].y ); 1643 | 1644 | 1645 | BitsPerCol = ROMBitSettingsForm->BitsPerColEdit->Text.ToIntDef(64); 1646 | BitsPerRow = ROMBitSettingsForm->BitsPerRowEdit->Text.ToIntDef(8); 1647 | BoxWidth = ROMBitSettingsForm->BoxWidthEdit->Text.ToIntDef(5); 1648 | BoxHeight = ROMBitSettingsForm->BoxHeightEdit->Text.ToIntDef(5); 1649 | Threshold0 = ROMBitSettingsForm->Threshold0Edit->Text.ToIntDef(64); 1650 | Threshold1 = ROMBitSettingsForm->Threshold1Edit->Text.ToIntDef(96); 1651 | 1652 | SettingsIni->WriteInteger( "BitSettings", "BitColumns", BitsPerCol ); 1653 | SettingsIni->WriteInteger( "BitSettings", "BitRows", BitsPerRow ); 1654 | SettingsIni->WriteInteger( "BitSettings", "BoxWidth", BoxWidth ); 1655 | SettingsIni->WriteInteger( "BitSettings", "BoxHeight", BoxHeight ); 1656 | SettingsIni->WriteInteger( "BitSettings", "Threshold0", Threshold0 ); 1657 | SettingsIni->WriteInteger( "BitSettings", "Threshold1", Threshold1 ); 1658 | SettingsIni->WriteInteger( "BitSettings", "MinBright1", ROMBitSettingsForm->MinBright1Edit->Text.ToIntDef(20) ); 1659 | SettingsIni->WriteInteger( "BitSettings", "MaxBright0", ROMBitSettingsForm->MaxBright0Edit->Text.ToIntDef(5) ); 1660 | SettingsIni->WriteInteger( "BitSettings", "BitAnalysisMethod", ROMBitSettingsForm->BitAnalysisMethodRadioGroup->ItemIndex ); 1661 | SettingsIni->WriteInteger( "BitSettings", "UseR", ROMBitSettingsForm->RedCheckBox->Checked ); 1662 | SettingsIni->WriteInteger( "BitSettings", "UseG", ROMBitSettingsForm->GreenCheckBox->Checked ); 1663 | SettingsIni->WriteInteger( "BitSettings", "UseB", ROMBitSettingsForm->BlueCheckBox->Checked ); 1664 | SettingsIni->WriteInteger( "BitSettings", "Dot1Threshold", ROMBitSettingsForm->Dot1ThresholdEdit->Text.ToIntDef(0) ); 1665 | SettingsIni->WriteInteger( "BitSettings", "Dot0Threshold", ROMBitSettingsForm->Dot0ThresholdEdit->Text.ToIntDef(0) ); 1666 | SettingsIni->WriteInteger( "BitSettings", "RimWidth", ROMBitSettingsForm->RimWidthEdit->Text.ToIntDef(1) ); 1667 | SettingsIni->WriteInteger( "BitSettings", "DotWidth", ROMBitSettingsForm->DotWidthEdit->Text.ToIntDef(1) ); 1668 | SettingsIni->WriteString( "BitSettings", "XBoxesToAnalyze", ROMBitSettingsForm->XBoxesToAnalyzeEdit->Text ); 1669 | SettingsIni->WriteString( "BitSettings", "YBoxesToAnalyze", ROMBitSettingsForm->YBoxesToAnalyzeEdit->Text ); 1670 | 1671 | SettingsIni->WriteString( "Image", "Filename", OpenFilename ); 1672 | 1673 | delete SettingsIni; 1674 | 1675 | if( OpenFilename.Length() ) 1676 | LogForm->LogMemo->Lines->Add( "Saved settings for "+OpenFilename ); 1677 | else 1678 | LogForm->LogMemo->Lines->Add( "Saved settings to file." ); 1679 | LogForm->LogMemo->Lines->Add( "" ); 1680 | } 1681 | //--------------------------------------------------------------------------- 1682 | -------------------------------------------------------------------------------- /ImageFrm.dfm: -------------------------------------------------------------------------------- 1 | object ImageForm: TImageForm 2 | Left = 928 3 | Top = 116 4 | Width = 726 5 | Height = 639 6 | Caption = 'Image' 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'MS Sans Serif' 12 | Font.Style = [] 13 | Menu = MainMenu 14 | OldCreateOrder = False 15 | Visible = True 16 | OnCreate = FormCreate 17 | OnDestroy = FormDestroy 18 | PixelsPerInch = 96 19 | TextHeight = 13 20 | object ImageView: TImageEnVect 21 | Left = 0 22 | Top = 0 23 | Width = 710 24 | Height = 581 25 | ParentCtl3D = False 26 | LegacyBitmap = False 27 | OnImageChange = ImageViewImageChange 28 | OnZoomIn = ImageViewZoomIn 29 | OnZoomOut = ImageViewZoomOut 30 | ImageEnVersion = '3.0.2' 31 | EnableInteractionHints = True 32 | Align = alClient 33 | TabOrder = 0 34 | OnDblClick = ImageViewDblClick 35 | OnMouseMove = ImageViewMouseMove 36 | OnKeyPress = ImageViewKeyPress 37 | OnVectorialChanged = ImageViewVectorialChanged 38 | end 39 | object MainMenu: TMainMenu 40 | Top = 8 41 | object File1: TMenuItem 42 | Caption = '&File' 43 | object OpenImageButton: TMenuItem 44 | Caption = '&Open image...' 45 | OnClick = OpenImageButtonClick 46 | end 47 | object Saveimageas1: TMenuItem 48 | Caption = '&Save image as...' 49 | OnClick = Saveimageas1Click 50 | end 51 | object Loadsettings1: TMenuItem 52 | Caption = '&Load settings...' 53 | OnClick = Loadsettings1Click 54 | end 55 | object Savesettings1: TMenuItem 56 | Caption = 'Save se&ttings...' 57 | OnClick = Savesettings1Click 58 | end 59 | object Exportbits1: TMenuItem 60 | Caption = '&Export bits to file...' 61 | OnClick = Exportbits1Click 62 | end 63 | end 64 | object Edit1: TMenuItem 65 | Caption = '&Edit' 66 | object Undo1: TMenuItem 67 | Caption = '&Undo image processing' 68 | ShortCut = 16474 69 | OnClick = Undo1Click 70 | end 71 | object Redo1: TMenuItem 72 | Caption = '&Redo image processing' 73 | ShortCut = 24666 74 | OnClick = Redo1Click 75 | end 76 | end 77 | object View1: TMenuItem 78 | Caption = '&View' 79 | object Fittowindow1: TMenuItem 80 | Caption = '&Fit to window' 81 | OnClick = Fittowindow1Click 82 | end 83 | object ZoomIn1: TMenuItem 84 | Caption = 'Zoom &In' 85 | OnClick = ZoomIn1Click 86 | end 87 | object ZoomOut1: TMenuItem 88 | Caption = 'Zoom &Out' 89 | OnClick = ZoomOut1Click 90 | end 91 | object Zoom1001: TMenuItem 92 | Caption = 'Zoom &100%' 93 | OnClick = Zoom1001Click 94 | end 95 | object Transparency1: TMenuItem 96 | Caption = 'Overlay transparency 0%' 97 | OnClick = Transparency1Click 98 | end 99 | object Transparency501: TMenuItem 100 | Caption = 'Overlay transparency 50%' 101 | OnClick = Transparency501Click 102 | end 103 | object Transparency801: TMenuItem 104 | Caption = 'Overlay transparency 80%' 105 | OnClick = Transparency801Click 106 | end 107 | end 108 | object Processing2: TMenuItem 109 | Caption = ' &Processing' 110 | object Processing1: TMenuItem 111 | Caption = 'Image &processing...' 112 | OnClick = Processing1Click 113 | end 114 | object Calcmultipliers1: TMenuItem 115 | Caption = '&Calc. flatfield multipliers' 116 | OnClick = Calcmultipliers1Click 117 | end 118 | object ApplyMultipliersButton: TMenuItem 119 | Caption = 'App&ly flatfield multipliers' 120 | OnClick = ApplyMultipliersButtonClick 121 | end 122 | end 123 | object Cursor1: TMenuItem 124 | Caption = '&Cursor' 125 | object EditPolyline1: TMenuItem 126 | Caption = 'Adjust box corners' 127 | OnClick = EditPolyline1Click 128 | end 129 | end 130 | object Objects1: TMenuItem 131 | Caption = '&Area Of Interest' 132 | object ShowROMBox1: TMenuItem 133 | Caption = 'Show Area Of Interest overlay' 134 | OnClick = ShowROMBox1Click 135 | end 136 | object ResetROMBox1: TMenuItem 137 | Caption = 'Reset AOI overlay' 138 | OnClick = ResetROMBox1Click 139 | end 140 | object Clearallobjects1: TMenuItem 141 | Caption = '&Clear bit-boxes' 142 | OnClick = Clearallobjects1Click 143 | end 144 | object FillROMBox1: TMenuItem 145 | Caption = 'Analyze bits within AOI' 146 | OnClick = FillROMBox1Click 147 | end 148 | end 149 | end 150 | object SaveImageDialog: TSaveDialog 151 | DefaultExt = '.jpg' 152 | FileName = 'capture' 153 | Filter = 154 | 'JPEG image (*.jpg)|*.jpg|TIFF image (*.tif)|*.tif|PNG image (*.p' + 155 | 'ng)|*.png|GIF image (*.gif)|*.gif|BMP image (*.bmp)|*.bmp' 156 | Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofEnableSizing] 157 | Title = 'Select filename for saved image' 158 | Left = 32 159 | end 160 | object ImageProc: TImageEnProc 161 | AttachedImageEn = ImageView 162 | Background = clBtnFace 163 | PreviewsParams = [prppShowResetButton, prppHardReset] 164 | PreviewFont.Charset = DEFAULT_CHARSET 165 | PreviewFont.Color = clWindowText 166 | PreviewFont.Height = -11 167 | PreviewFont.Name = 'MS Sans Serif' 168 | PreviewFont.Style = [] 169 | Left = 80 170 | Top = 16 171 | end 172 | object OpenImageDialog: TOpenDialog 173 | Filter = 174 | 'Image files (*.tif;*.jpg;*.png;*.bmp)|*.tif;*.jpg;*.png;*.bmp|TI' + 175 | 'FF files (*.tif)|*.tif|JPEG files (*.jpg)|*.jpg|PNG files (*.png' + 176 | ')|*.png|BMP files (*.bmp)|*.bmp' 177 | Options = [ofHideReadOnly, ofPathMustExist, ofFileMustExist, ofEnableSizing] 178 | Left = 40 179 | Top = 72 180 | end 181 | object ROMBitSaveDialog: TSaveDialog 182 | DefaultExt = '.txt' 183 | Filter = 'Text files|*.txt' 184 | Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofEnableSizing] 185 | Left = 8 186 | Top = 32 187 | end 188 | object OpenSettingsDialog: TOpenDialog 189 | DefaultExt = '.ini' 190 | Filter = 'Settings files (*.ini)|*.ini' 191 | Options = [ofHideReadOnly, ofPathMustExist, ofFileMustExist, ofEnableSizing] 192 | Title = 'Load bitract settings file...' 193 | Left = 72 194 | Top = 72 195 | end 196 | object SaveSettingsDialog: TSaveDialog 197 | DefaultExt = '.ini' 198 | FileName = 'bitsettings' 199 | Filter = 'Settings files (*.ini)|*.ini' 200 | Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofEnableSizing] 201 | Title = 'Save settings...' 202 | Left = 72 203 | Top = 96 204 | end 205 | end 206 | -------------------------------------------------------------------------------- /ImageFrm.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef ImageFrmH 4 | #define ImageFrmH 5 | //--------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "ieview.hpp" 11 | #include "imageenio.hpp" 12 | #include "imageenview.hpp" 13 | #include 14 | #include 15 | #include 16 | #include "imageenproc.hpp" 17 | #include "ievect.hpp" 18 | //--------------------------------------------------------------------------- 19 | struct _ROMBit 20 | { 21 | int Box; // hobj of the object for this box 22 | TRGB PixelSum; // pixelsum for each of RGB 23 | int PixelSumG; // gray pixelsum (selected channels mixed) 24 | int Value; // 0/1/-1 25 | TPoint Pos; // x,y position in grid of bits 26 | int PixelsAboveThreshold; 27 | int PixelsBelowThreshold; 28 | int RimLevel; 29 | int DotLevel; 30 | 31 | int Active; // 1 if this is a visible bit (analyze it), 0 if it is not a real bit 32 | }; 33 | //--------------------------------------------------------------------------- 34 | class TImageForm : public TForm 35 | { 36 | __published: // IDE-managed Components 37 | TMainMenu *MainMenu; 38 | TMenuItem *File1; 39 | TMenuItem *Saveimageas1; 40 | TSaveDialog *SaveImageDialog; 41 | TImageEnProc *ImageProc; 42 | TMenuItem *View1; 43 | TMenuItem *Zoom1001; 44 | TMenuItem *OpenImageButton; 45 | TMenuItem *Calcmultipliers1; 46 | TMenuItem *ApplyMultipliersButton; 47 | TOpenDialog *OpenImageDialog; 48 | TImageEnVect *ImageView; 49 | TMenuItem *ShowROMBox1; 50 | TMenuItem *Cursor1; 51 | TMenuItem *EditPolyline1; 52 | TMenuItem *FillROMBox1; 53 | TMenuItem *Objects1; 54 | TMenuItem *Clearallobjects1; 55 | TMenuItem *Transparency1; 56 | TMenuItem *Transparency501; 57 | TMenuItem *Transparency801; 58 | TMenuItem *Processing1; 59 | TMenuItem *Edit1; 60 | TMenuItem *Undo1; 61 | TMenuItem *Redo1; 62 | TMenuItem *Processing2; 63 | TMenuItem *Fittowindow1; 64 | TMenuItem *ZoomIn1; 65 | TMenuItem *ZoomOut1; 66 | TMenuItem *ResetROMBox1; 67 | TMenuItem *Exportbits1; 68 | TSaveDialog *ROMBitSaveDialog; 69 | TMenuItem *Loadsettings1; 70 | TMenuItem *Savesettings1; 71 | TOpenDialog *OpenSettingsDialog; 72 | TSaveDialog *SaveSettingsDialog; 73 | void __fastcall Saveimageas1Click(TObject *Sender); 74 | void __fastcall FormCreate(TObject *Sender); 75 | void __fastcall FormDestroy(TObject *Sender); 76 | void __fastcall Zoom1001Click(TObject *Sender); 77 | void __fastcall ImageViewZoomIn(TObject *Sender, double &NewZoom); 78 | void __fastcall ImageViewZoomOut(TObject *Sender, double &NewZoom); 79 | void __fastcall ImageViewImageChange(TObject *Sender); 80 | void __fastcall Calcmultipliers1Click(TObject *Sender); 81 | void __fastcall ApplyMultipliersButtonClick(TObject *Sender); 82 | void __fastcall OpenImageButtonClick(TObject *Sender); 83 | void __fastcall ShowROMBox1Click(TObject *Sender); 84 | void __fastcall EditPolyline1Click(TObject *Sender); 85 | void __fastcall FillROMBox1Click(TObject *Sender); 86 | void __fastcall Clearallobjects1Click(TObject *Sender); 87 | void __fastcall Transparency1Click(TObject *Sender); 88 | void __fastcall Transparency501Click(TObject *Sender); 89 | void __fastcall Transparency801Click(TObject *Sender); 90 | void __fastcall ImageViewMouseMove(TObject *Sender, TShiftState Shift, 91 | int X, int Y); 92 | void __fastcall Processing1Click(TObject *Sender); 93 | void __fastcall Undo1Click(TObject *Sender); 94 | void __fastcall Redo1Click(TObject *Sender); 95 | void __fastcall ImageViewDblClick(TObject *Sender); 96 | void __fastcall ImageViewKeyPress(TObject *Sender, char &Key); 97 | void __fastcall ImageViewVectorialChanged(TObject *Sender); 98 | void __fastcall Fittowindow1Click(TObject *Sender); 99 | void __fastcall ZoomIn1Click(TObject *Sender); 100 | void __fastcall ZoomOut1Click(TObject *Sender); 101 | void __fastcall ResetROMBox1Click(TObject *Sender); 102 | void __fastcall FillBitView(void); 103 | void __fastcall Exportbits1Click(TObject *Sender); 104 | void __fastcall ImageViewObjectClick(TObject *Sender, int hobj); 105 | void __fastcall Loadsettings1Click(TObject *Sender); 106 | void __fastcall LoadSettings( AnsiString IniFilename ); 107 | void __fastcall Savesettings1Click(TObject *Sender); 108 | void __fastcall SaveSettings(AnsiString IniFilename); 109 | 110 | private: // User declarations 111 | public: // User declarations 112 | __fastcall TImageForm(TComponent* Owner); 113 | 114 | void __fastcall UpdateCaption(void); 115 | 116 | double *MultiplierR; 117 | double *MultiplierG; 118 | double *MultiplierB; 119 | 120 | int ROMPolygon; 121 | int NumROMBits; 122 | struct _ROMBit *ROMBit; 123 | 124 | AnsiString OpenFilename; 125 | AnsiString WorkingDir; 126 | 127 | AnsiString PreviousFilename; // filename loaded from settings file 128 | 129 | int XBoxesPatternLen; 130 | int *XBoxesPattern; 131 | int YBoxesPatternLen; 132 | int *YBoxesPattern; 133 | }; 134 | //--------------------------------------------------------------------------- 135 | extern PACKAGE TImageForm *ImageForm; 136 | //--------------------------------------------------------------------------- 137 | #endif 138 | -------------------------------------------------------------------------------- /LogFrm.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #pragma hdrstop 5 | 6 | #include "LogFrm.h" 7 | #include "ImageFrm.h" 8 | #include "HistogramFrm.h" 9 | #include "ROMBitSettingsFrm.h" 10 | //--------------------------------------------------------------------------- 11 | #pragma package(smart_init) 12 | #pragma resource "*.dfm" 13 | 14 | TCriticalSection *StageCmd; // TCriticalSection for accessing CmdToExec/X/Y/StepSize 15 | 16 | TLogForm *LogForm; 17 | //--------------------------------------------------------------------------- 18 | __fastcall TLogForm::TLogForm(TComponent* Owner) 19 | : TForm(Owner) 20 | { 21 | StageCmd=new TCriticalSection; // create StageCmd TCriticalSection 22 | } 23 | //--------------------------------------------------------------------------- 24 | void __fastcall TLogForm::FormCreate(TObject *Sender) 25 | { 26 | // read .ini file to setup form (x/y position etc) 27 | TIniFile *PicturizatronIni; 28 | 29 | PicturizatronIni = new TIniFile( ChangeFileExt( Application->ExeName, ".ini" ) ); 30 | Top = PicturizatronIni->ReadInteger( "LogForm", "Top", 0 ); // LogForm goes at top left of screen 31 | Left = PicturizatronIni->ReadInteger( "LogForm", "Left", 0 ); 32 | 33 | delete PicturizatronIni; 34 | } 35 | //--------------------------------------------------------------------------- 36 | void __fastcall TLogForm::Exit1Click(TObject *Sender) 37 | { 38 | Close(); 39 | } 40 | //--------------------------------------------------------------------------- 41 | void __fastcall TLogForm::Image1Click(TObject *Sender) 42 | { 43 | ImageForm->Show(); 44 | } 45 | //--------------------------------------------------------------------------- 46 | void __fastcall TLogForm::FormDestroy(TObject *Sender) 47 | { 48 | // write .ini file to save form setup (x/y position etc) 49 | TIniFile *PicturizatronIni; 50 | 51 | PicturizatronIni = new TIniFile( ChangeFileExt( Application->ExeName, ".ini" ) ); 52 | PicturizatronIni->WriteInteger( "LogForm", "Top", Top ); // save top/left of form 53 | PicturizatronIni->WriteInteger( "LogForm", "Left", Left ); 54 | PicturizatronIni->WriteInteger( "LogForm", "Width", Width ); // save width/height of form 55 | PicturizatronIni->WriteInteger( "LogForm", "Height", Height ); 56 | 57 | delete PicturizatronIni; 58 | } 59 | //--------------------------------------------------------------------------- 60 | void __fastcall TLogForm::Histogram1Click(TObject *Sender) 61 | { 62 | HistogramForm->Show(); 63 | } 64 | //--------------------------------------------------------------------------- 65 | void __fastcall TLogForm::ROMBitSettings1Click(TObject *Sender) 66 | { 67 | ROMBitSettingsForm->Show(); 68 | } 69 | //--------------------------------------------------------------------------- 70 | -------------------------------------------------------------------------------- /LogFrm.dfm: -------------------------------------------------------------------------------- 1 | object LogForm: TLogForm 2 | Left = 184 3 | Top = 121 4 | Width = 632 5 | Height = 232 6 | Caption = 'Bitract: The ROM Bit Extraction System' 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'MS Sans Serif' 12 | Font.Style = [] 13 | Menu = MainMenu 14 | OldCreateOrder = False 15 | Visible = True 16 | OnCreate = FormCreate 17 | OnDestroy = FormDestroy 18 | PixelsPerInch = 96 19 | TextHeight = 13 20 | object LogMemo: TMemo 21 | Left = 0 22 | Top = 0 23 | Width = 616 24 | Height = 174 25 | Align = alClient 26 | Lines.Strings = ( 27 | 'Welcome to Bitract: The ROM Bit Extraction System' 28 | '' 29 | 30 | 'To start the bit extraction process, open an Image using "File -' + 31 | '>Open image..."' 32 | '') 33 | ScrollBars = ssVertical 34 | TabOrder = 0 35 | end 36 | object MainMenu: TMainMenu 37 | object File1: TMenuItem 38 | Caption = '&File' 39 | object Exit1: TMenuItem 40 | Caption = 'E&xit' 41 | OnClick = Exit1Click 42 | end 43 | end 44 | object Window1: TMenuItem 45 | Caption = '&Window' 46 | object Image1: TMenuItem 47 | Caption = 'Image' 48 | OnClick = Image1Click 49 | end 50 | object Histogram1: TMenuItem 51 | Caption = 'Image &Histogram' 52 | OnClick = Histogram1Click 53 | end 54 | object ROMBitSettings1: TMenuItem 55 | Caption = 'Bit Settings' 56 | OnClick = ROMBitSettings1Click 57 | end 58 | end 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /LogFrm.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef LogFrmH 4 | #define LogFrmH 5 | //--------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | //--------------------------------------------------------------------------- 13 | class TLogForm : public TForm 14 | { 15 | __published: // IDE-managed Components 16 | TMemo *LogMemo; 17 | TMainMenu *MainMenu; 18 | TMenuItem *File1; 19 | TMenuItem *Exit1; 20 | TMenuItem *Window1; 21 | TMenuItem *Image1; 22 | TMenuItem *Histogram1; 23 | TMenuItem *ROMBitSettings1; 24 | void __fastcall FormCreate(TObject *Sender); 25 | void __fastcall Exit1Click(TObject *Sender); 26 | void __fastcall Image1Click(TObject *Sender); 27 | void __fastcall FormDestroy(TObject *Sender); 28 | void __fastcall Histogram1Click(TObject *Sender); 29 | void __fastcall ROMBitSettings1Click(TObject *Sender); 30 | private: // User declarations 31 | public: // User declarations 32 | __fastcall TLogForm(TComponent* Owner); 33 | }; 34 | //--------------------------------------------------------------------------- 35 | extern TCriticalSection *StageCmd; // TCriticalSection for accessing CmdToExec/X/Y/StepSize 36 | //--------------------------------------------------------------------------- 37 | extern PACKAGE TLogForm *LogForm; 38 | //--------------------------------------------------------------------------- 39 | #endif 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bitract 2 | 3 | Extract bits from photos 4 | 5 | As released at Hardwear.io 2019 6 | 7 | https://media.hardwear.io/bits-from-the-matrix-optical-rom-extraction-chris-gerlinsky/ 8 | 9 | See also: https://github.com/SiliconAnalysis/bitviewer 10 | -------------------------------------------------------------------------------- /ROMBitSettingsFrm.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #include 5 | #pragma hdrstop 6 | 7 | #include "ROMBitSettingsFrm.h" 8 | #include "ImageFrm.h" 9 | #include "LogFrm.h" 10 | //--------------------------------------------------------------------------- 11 | #pragma package(smart_init) 12 | #pragma link "histogrambox" 13 | #pragma link "ievect" 14 | #pragma link "ieview" 15 | #pragma link "imageenview" 16 | #pragma link "imageenproc" 17 | #pragma resource "*.dfm" 18 | TROMBitSettingsForm *ROMBitSettingsForm; 19 | //--------------------------------------------------------------------------- 20 | __fastcall TROMBitSettingsForm::TROMBitSettingsForm(TComponent* Owner) 21 | : TForm(Owner) 22 | { 23 | } 24 | //--------------------------------------------------------------------------- 25 | void __fastcall TROMBitSettingsForm::FormCreate(TObject *Sender) 26 | { 27 | // read .ini file to setup form (x/y position etc) 28 | TIniFile *PicturizatronIni; 29 | 30 | PicturizatronIni = new TIniFile( ChangeFileExt( Application->ExeName, ".ini" ) ); 31 | Top = PicturizatronIni->ReadInteger( "ROMBitSettingsForm", "Top", LogForm->Top+LogForm->Height ); 32 | Left = PicturizatronIni->ReadInteger( "ROMBitSettingsForm", "Left", 0 ); 33 | Width = PicturizatronIni->ReadInteger( "ROMBitSettingsForm", "Width", Width ); 34 | Height = PicturizatronIni->ReadInteger( "ROMBitSettingsForm", "Height", Height ); 35 | 36 | delete PicturizatronIni; 37 | } 38 | //--------------------------------------------------------------------------- 39 | void __fastcall TROMBitSettingsForm::FormDestroy(TObject *Sender) 40 | { 41 | // write .ini file to save form setup (x/y position etc) 42 | TIniFile *PicturizatronIni; 43 | 44 | PicturizatronIni = new TIniFile( ChangeFileExt( Application->ExeName, ".ini" ) ); 45 | PicturizatronIni->WriteInteger( "ROMBitSettingsForm", "Top", Top ); // save top/left of form 46 | PicturizatronIni->WriteInteger( "ROMBitSettingsForm", "Left", Left ); 47 | PicturizatronIni->WriteInteger( "ROMBitSettingsForm", "Width", Width ); // save width/height of form 48 | PicturizatronIni->WriteInteger( "ROMBitSettingsForm", "Height", Height ); 49 | 50 | delete PicturizatronIni; 51 | } 52 | //--------------------------------------------------------------------------- 53 | void __fastcall TROMBitSettingsForm::TabSheet1Resize(TObject *Sender) 54 | { 55 | if( TabSheet1->Width > 50 ) 56 | HistogramBox->Width = TabSheet1->Width-32; 57 | 58 | if( TabSheet1->Height > 60 ) 59 | HistogramBox->Height = TabSheet1->Height-42; 60 | } 61 | //--------------------------------------------------------------------------- 62 | void __fastcall TROMBitSettingsForm::BitHistRedCheckBoxClick( 63 | TObject *Sender) 64 | { 65 | THistogramKind TempHistogramKind; 66 | 67 | if( BitHistRedCheckBox->Checked ) 68 | TempHistogramKind << hkRed; 69 | 70 | if( BitHistGreenCheckBox->Checked ) 71 | TempHistogramKind << hkGreen; 72 | 73 | if( BitHistBlueCheckBox->Checked ) 74 | TempHistogramKind << hkBlue; 75 | 76 | if( BitHistGrayCheckBox->Checked ) 77 | TempHistogramKind << hkGray; 78 | 79 | HistogramBox->HistogramKind = TempHistogramKind; 80 | } 81 | //--------------------------------------------------------------------------- 82 | void __fastcall TROMBitSettingsForm::BitsPerColEditKeyPress( 83 | TObject *Sender, char &Key) 84 | { 85 | if( Key=='\r' ) 86 | { 87 | ImageForm->FillROMBox1Click(NULL); 88 | Key = 0; 89 | } 90 | } 91 | //--------------------------------------------------------------------------- 92 | void __fastcall TROMBitSettingsForm::YBoxesToAnalyzeEditKeyPress( 93 | TObject *Sender, char &Key) 94 | { 95 | if( Key=='\r' ) 96 | { 97 | ImageForm->FillROMBox1Click(NULL); 98 | Key = 0; 99 | } 100 | switch( Key ) 101 | { 102 | case '\b': 103 | case '0': 104 | case '1': 105 | break; 106 | 107 | default: 108 | Key = 0; 109 | break; 110 | } 111 | } 112 | //--------------------------------------------------------------------------- 113 | 114 | -------------------------------------------------------------------------------- /ROMBitSettingsFrm.dfm: -------------------------------------------------------------------------------- 1 | object ROMBitSettingsForm: TROMBitSettingsForm 2 | Left = 645 3 | Top = 112 4 | Width = 632 5 | Height = 370 6 | Caption = 'Bit analysis settings' 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'MS Sans Serif' 12 | Font.Style = [] 13 | OldCreateOrder = False 14 | Visible = True 15 | OnCreate = FormCreate 16 | OnDestroy = FormDestroy 17 | DesignSize = ( 18 | 616 19 | 332) 20 | PixelsPerInch = 96 21 | TextHeight = 13 22 | object Label1: TLabel 23 | Left = 47 24 | Top = 4 25 | Width = 75 26 | Height = 13 27 | Caption = 'Bits across AOI:' 28 | end 29 | object Label2: TLabel 30 | Left = 16 31 | Top = 44 32 | Width = 106 33 | Height = 13 34 | Caption = 'Bits up and down AOI:' 35 | end 36 | object Label3: TLabel 37 | Left = 250 38 | Top = 12 39 | Width = 63 40 | Height = 13 41 | Caption = 'Bit-box width:' 42 | end 43 | object Label4: TLabel 44 | Left = 246 45 | Top = 36 46 | Width = 67 47 | Height = 13 48 | Caption = 'Bit-box height:' 49 | end 50 | object Label6: TLabel 51 | Left = 209 52 | Top = 92 53 | Width = 104 54 | Height = 13 55 | Caption = 'Max. '#39'0'#39' bit brightness:' 56 | end 57 | object Label7: TLabel 58 | Left = 212 59 | Top = 68 60 | Width = 101 61 | Height = 13 62 | Caption = 'Min. '#39'1'#39' bit brightness:' 63 | end 64 | object Label10: TLabel 65 | Left = 196 66 | Top = 290 67 | Width = 98 68 | Height = 13 69 | Caption = 'Channels to analyze:' 70 | end 71 | object Label11: TLabel 72 | Left = 4 73 | Top = 20 74 | Width = 115 75 | Height = 13 76 | Caption = '(# of horizontal columns)' 77 | end 78 | object Label12: TLabel 79 | Left = 32 80 | Top = 60 81 | Width = 87 82 | Height = 13 83 | Caption = '(# of vertical rows)' 84 | end 85 | object Label8: TLabel 86 | Left = 196 87 | Top = 124 88 | Width = 119 89 | Height = 13 90 | Caption = 'Min. # bright pixels for '#39'1'#39':' 91 | end 92 | object Label9: TLabel 93 | Left = 193 94 | Top = 148 95 | Width = 122 96 | Height = 13 97 | Caption = 'Max. # bright pixels for '#39'0'#39':' 98 | end 99 | object Label15: TLabel 100 | Left = 266 101 | Top = 188 102 | Width = 49 103 | Height = 13 104 | Caption = 'Rim width:' 105 | end 106 | object Label17: TLabel 107 | Left = 267 108 | Top = 212 109 | Width = 48 110 | Height = 13 111 | Caption = 'Dot width:' 112 | end 113 | object Label18: TLabel 114 | Left = 134 115 | Top = 188 116 | Width = 75 117 | Height = 13 118 | Caption = 'Dot 1 threshold:' 119 | end 120 | object Label19: TLabel 121 | Left = 134 122 | Top = 212 123 | Width = 75 124 | Height = 13 125 | Caption = 'Dot 0 threshold:' 126 | end 127 | object Label20: TLabel 128 | Left = 12 129 | Top = 252 130 | Width = 58 131 | Height = 13 132 | BiDiMode = bdLeftToRight 133 | Caption = '# pixels dim:' 134 | ParentBiDiMode = False 135 | end 136 | object Label21: TLabel 137 | Left = 73 138 | Top = 252 139 | Width = 40 140 | Height = 13 141 | AutoSize = False 142 | Caption = '-1' 143 | end 144 | object Label23: TLabel 145 | Left = 142 146 | Top = 244 147 | Width = 92 148 | Height = 13 149 | Caption = 'X boxes to analyze:' 150 | end 151 | object Label25: TLabel 152 | Left = 142 153 | Top = 268 154 | Width = 92 155 | Height = 13 156 | Caption = 'Y boxes to analyze:' 157 | end 158 | object BitsPerColEdit: TEdit 159 | Left = 128 160 | Top = 8 161 | Width = 49 162 | Height = 21 163 | TabOrder = 0 164 | Text = '32' 165 | OnKeyPress = BitsPerColEditKeyPress 166 | end 167 | object BitsPerRowEdit: TEdit 168 | Left = 128 169 | Top = 48 170 | Width = 49 171 | Height = 21 172 | TabOrder = 1 173 | Text = '32' 174 | OnKeyPress = BitsPerColEditKeyPress 175 | end 176 | object BoxWidthEdit: TEdit 177 | Left = 320 178 | Top = 8 179 | Width = 41 180 | Height = 21 181 | TabOrder = 4 182 | Text = '10' 183 | OnKeyPress = BitsPerColEditKeyPress 184 | end 185 | object BoxHeightEdit: TEdit 186 | Left = 320 187 | Top = 32 188 | Width = 41 189 | Height = 21 190 | TabOrder = 5 191 | Text = '10' 192 | OnKeyPress = BitsPerColEditKeyPress 193 | end 194 | object Threshold0Edit: TEdit 195 | Left = 320 196 | Top = 88 197 | Width = 41 198 | Height = 21 199 | TabOrder = 7 200 | Text = '58' 201 | OnKeyPress = BitsPerColEditKeyPress 202 | end 203 | object Threshold1Edit: TEdit 204 | Left = 320 205 | Top = 64 206 | Width = 41 207 | Height = 21 208 | TabOrder = 6 209 | Text = '72' 210 | OnKeyPress = BitsPerColEditKeyPress 211 | end 212 | object PageControl: TPageControl 213 | Left = 376 214 | Top = 0 215 | Width = 264 216 | Height = 343 217 | ActivePage = TabSheet2 218 | Anchors = [akLeft, akTop, akRight, akBottom] 219 | TabIndex = 1 220 | TabOrder = 13 221 | object TabSheet1: TTabSheet 222 | Caption = 'Bits Histogram' 223 | OnResize = TabSheet1Resize 224 | DesignSize = ( 225 | 256 226 | 315) 227 | object HistogramBox: THistogramBox 228 | Left = 5 229 | Top = -1 230 | Width = 224 231 | Height = 162 232 | AttachedImageEnProc = BitViewProc 233 | HistogramKind = [hkRed, hkGreen, hkBlue] 234 | end 235 | object BitHistRedCheckBox: TCheckBox 236 | Left = 8 237 | Top = 281 238 | Width = 49 239 | Height = 17 240 | Anchors = [akLeft, akBottom] 241 | Caption = 'Red' 242 | Checked = True 243 | State = cbChecked 244 | TabOrder = 1 245 | OnClick = BitHistRedCheckBoxClick 246 | end 247 | object BitHistGreenCheckBox: TCheckBox 248 | Left = 64 249 | Top = 281 250 | Width = 57 251 | Height = 17 252 | Anchors = [akLeft, akBottom] 253 | Caption = 'Green' 254 | Checked = True 255 | State = cbChecked 256 | TabOrder = 2 257 | OnClick = BitHistRedCheckBoxClick 258 | end 259 | object BitHistBlueCheckBox: TCheckBox 260 | Left = 128 261 | Top = 281 262 | Width = 57 263 | Height = 17 264 | Anchors = [akLeft, akBottom] 265 | Caption = 'Blue' 266 | Checked = True 267 | State = cbChecked 268 | TabOrder = 3 269 | OnClick = BitHistRedCheckBoxClick 270 | end 271 | object BitHistGrayCheckBox: TCheckBox 272 | Left = 182 273 | Top = 281 274 | Width = 46 275 | Height = 17 276 | Anchors = [akLeft, akBottom] 277 | Caption = 'Gray' 278 | TabOrder = 4 279 | OnClick = BitHistRedCheckBoxClick 280 | end 281 | end 282 | object TabSheet2: TTabSheet 283 | Caption = 'Bits-only Image' 284 | ImageIndex = 1 285 | DesignSize = ( 286 | 256 287 | 315) 288 | object BitView: TImageEnVect 289 | Left = 0 290 | Top = 0 291 | Width = 234 292 | Height = 306 293 | ParentCtl3D = False 294 | ImageEnVersion = '3.0.2' 295 | Anchors = [akLeft, akTop, akRight, akBottom] 296 | EnableInteractionHints = True 297 | TabOrder = 0 298 | end 299 | end 300 | end 301 | object RedCheckBox: TCheckBox 302 | Left = 168 303 | Top = 304 304 | Width = 49 305 | Height = 17 306 | Caption = 'Red' 307 | Checked = True 308 | State = cbChecked 309 | TabOrder = 10 310 | end 311 | object GreenCheckBox: TCheckBox 312 | Left = 224 313 | Top = 304 314 | Width = 57 315 | Height = 17 316 | Caption = 'Green' 317 | Checked = True 318 | State = cbChecked 319 | TabOrder = 11 320 | end 321 | object BlueCheckBox: TCheckBox 322 | Left = 288 323 | Top = 304 324 | Width = 57 325 | Height = 17 326 | Caption = 'Blue' 327 | Checked = True 328 | State = cbChecked 329 | TabOrder = 12 330 | end 331 | object BitBoxInfoGroupBox: TGroupBox 332 | Left = 8 333 | Top = 172 334 | Width = 117 335 | Height = 117 336 | Caption = 'Bit-box under mouse' 337 | TabOrder = 3 338 | object Label13: TLabel 339 | Left = 19 340 | Top = 20 341 | Width = 51 342 | Height = 13 343 | Caption = 'Bit-box idx:' 344 | end 345 | object Label14: TLabel 346 | Left = 5 347 | Top = 36 348 | Width = 65 349 | Height = 13 350 | BiDiMode = bdLeftToRight 351 | Caption = 'Sum of pixels:' 352 | ParentBiDiMode = False 353 | end 354 | object BitBoxIdxLabel: TLabel 355 | Left = 73 356 | Top = 20 357 | Width = 40 358 | Height = 13 359 | AutoSize = False 360 | Caption = '-1' 361 | end 362 | object PixelSumLabel: TLabel 363 | Left = 73 364 | Top = 36 365 | Width = 40 366 | Height = 13 367 | AutoSize = False 368 | Caption = '-1' 369 | end 370 | object Label5: TLabel 371 | Left = 2 372 | Top = 52 373 | Width = 68 374 | Height = 13 375 | BiDiMode = bdLeftToRight 376 | Caption = '# pixels bright:' 377 | ParentBiDiMode = False 378 | end 379 | object PixelsAboveThresholdLabel: TLabel 380 | Left = 73 381 | Top = 52 382 | Width = 40 383 | Height = 13 384 | AutoSize = False 385 | Caption = '-1' 386 | end 387 | object Label16: TLabel 388 | Left = 12 389 | Top = 68 390 | Width = 58 391 | Height = 13 392 | BiDiMode = bdLeftToRight 393 | Caption = '# pixels dim:' 394 | ParentBiDiMode = False 395 | end 396 | object PixelsBelowThresholdLabel: TLabel 397 | Left = 73 398 | Top = 68 399 | Width = 40 400 | Height = 13 401 | AutoSize = False 402 | Caption = '-1' 403 | end 404 | object Label22: TLabel 405 | Left = 25 406 | Top = 84 407 | Width = 45 408 | Height = 13 409 | BiDiMode = bdLeftToRight 410 | Caption = 'Dot level:' 411 | ParentBiDiMode = False 412 | end 413 | object DotLevelLabel: TLabel 414 | Left = 73 415 | Top = 84 416 | Width = 40 417 | Height = 13 418 | AutoSize = False 419 | Caption = '-1' 420 | end 421 | object Label24: TLabel 422 | Left = 24 423 | Top = 100 424 | Width = 46 425 | Height = 13 426 | BiDiMode = bdLeftToRight 427 | Caption = 'Rim level:' 428 | ParentBiDiMode = False 429 | end 430 | object RimLevelLabel: TLabel 431 | Left = 73 432 | Top = 100 433 | Width = 40 434 | Height = 13 435 | AutoSize = False 436 | Caption = '-1' 437 | end 438 | end 439 | object MinBright1Edit: TEdit 440 | Left = 320 441 | Top = 120 442 | Width = 41 443 | Height = 21 444 | TabOrder = 8 445 | Text = '20' 446 | OnKeyPress = BitsPerColEditKeyPress 447 | end 448 | object MaxBright0Edit: TEdit 449 | Left = 320 450 | Top = 144 451 | Width = 41 452 | Height = 21 453 | TabOrder = 9 454 | Text = '5' 455 | OnKeyPress = BitsPerColEditKeyPress 456 | end 457 | object BitAnalysisMethodRadioGroup: TRadioGroup 458 | Left = 8 459 | Top = 88 460 | Width = 177 461 | Height = 73 462 | Caption = 'Bit analysis method' 463 | ItemIndex = 0 464 | Items.Strings = ( 465 | 'Avg. brightness within bit-box' 466 | '# of bright pixels within bit-box' 467 | 'Dot finder') 468 | TabOrder = 2 469 | end 470 | object RimWidthEdit: TEdit 471 | Left = 320 472 | Top = 184 473 | Width = 41 474 | Height = 21 475 | TabOrder = 14 476 | Text = '2' 477 | OnKeyPress = BitsPerColEditKeyPress 478 | end 479 | object DotWidthEdit: TEdit 480 | Left = 320 481 | Top = 208 482 | Width = 41 483 | Height = 21 484 | TabOrder = 15 485 | Text = '2' 486 | OnKeyPress = BitsPerColEditKeyPress 487 | end 488 | object Dot1ThresholdEdit: TEdit 489 | Left = 216 490 | Top = 184 491 | Width = 41 492 | Height = 21 493 | TabOrder = 16 494 | Text = '20' 495 | OnKeyPress = BitsPerColEditKeyPress 496 | end 497 | object Dot0ThresholdEdit: TEdit 498 | Left = 216 499 | Top = 208 500 | Width = 41 501 | Height = 21 502 | TabOrder = 17 503 | Text = '10' 504 | OnKeyPress = BitsPerColEditKeyPress 505 | end 506 | object XBoxesToAnalyzeEdit: TEdit 507 | Left = 240 508 | Top = 240 509 | Width = 121 510 | Height = 21 511 | TabOrder = 18 512 | Text = '1' 513 | OnKeyPress = YBoxesToAnalyzeEditKeyPress 514 | end 515 | object YBoxesToAnalyzeEdit: TEdit 516 | Left = 240 517 | Top = 264 518 | Width = 121 519 | Height = 21 520 | TabOrder = 19 521 | Text = '1' 522 | OnKeyPress = YBoxesToAnalyzeEditKeyPress 523 | end 524 | object BitViewProc: TImageEnProc 525 | AttachedImageEn = BitView 526 | Background = clBtnFace 527 | PreviewsParams = [prppShowResetButton, prppHardReset] 528 | PreviewFont.Charset = DEFAULT_CHARSET 529 | PreviewFont.Color = clWindowText 530 | PreviewFont.Height = -11 531 | PreviewFont.Name = 'MS Sans Serif' 532 | PreviewFont.Style = [] 533 | Left = 200 534 | end 535 | end 536 | -------------------------------------------------------------------------------- /ROMBitSettingsFrm.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef ROMBitSettingsFrmH 4 | #define ROMBitSettingsFrmH 5 | //--------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "histogrambox.hpp" 13 | #include "ievect.hpp" 14 | #include "ieview.hpp" 15 | #include "imageenview.hpp" 16 | #include "imageenproc.hpp" 17 | #include 18 | //--------------------------------------------------------------------------- 19 | class TROMBitSettingsForm : public TForm 20 | { 21 | __published: // IDE-managed Components 22 | TLabel *Label1; 23 | TLabel *Label2; 24 | TLabel *Label3; 25 | TLabel *Label4; 26 | TLabel *Label6; 27 | TLabel *Label7; 28 | TEdit *BitsPerColEdit; 29 | TEdit *BitsPerRowEdit; 30 | TEdit *BoxWidthEdit; 31 | TEdit *BoxHeightEdit; 32 | TEdit *Threshold0Edit; 33 | TEdit *Threshold1Edit; 34 | TPageControl *PageControl; 35 | TTabSheet *TabSheet1; 36 | TTabSheet *TabSheet2; 37 | THistogramBox *HistogramBox; 38 | TImageEnVect *BitView; 39 | TImageEnProc *BitViewProc; 40 | TCheckBox *BitHistRedCheckBox; 41 | TCheckBox *BitHistGreenCheckBox; 42 | TCheckBox *BitHistBlueCheckBox; 43 | TCheckBox *BitHistGrayCheckBox; 44 | TCheckBox *RedCheckBox; 45 | TCheckBox *GreenCheckBox; 46 | TCheckBox *BlueCheckBox; 47 | TLabel *Label10; 48 | TLabel *Label11; 49 | TLabel *Label12; 50 | TGroupBox *BitBoxInfoGroupBox; 51 | TLabel *Label13; 52 | TLabel *Label14; 53 | TLabel *BitBoxIdxLabel; 54 | TLabel *PixelSumLabel; 55 | TLabel *Label8; 56 | TEdit *MinBright1Edit; 57 | TLabel *Label9; 58 | TEdit *MaxBright0Edit; 59 | TRadioGroup *BitAnalysisMethodRadioGroup; 60 | TLabel *Label5; 61 | TLabel *PixelsAboveThresholdLabel; 62 | TLabel *Label16; 63 | TLabel *PixelsBelowThresholdLabel; 64 | TLabel *Label15; 65 | TEdit *RimWidthEdit; 66 | TLabel *Label17; 67 | TEdit *DotWidthEdit; 68 | TLabel *Label18; 69 | TEdit *Dot1ThresholdEdit; 70 | TLabel *Label19; 71 | TEdit *Dot0ThresholdEdit; 72 | TLabel *Label20; 73 | TLabel *Label21; 74 | TLabel *Label22; 75 | TLabel *DotLevelLabel; 76 | TLabel *Label24; 77 | TLabel *RimLevelLabel; 78 | TLabel *Label23; 79 | TEdit *XBoxesToAnalyzeEdit; 80 | TLabel *Label25; 81 | TEdit *YBoxesToAnalyzeEdit; 82 | void __fastcall FormCreate(TObject *Sender); 83 | void __fastcall FormDestroy(TObject *Sender); 84 | void __fastcall TabSheet1Resize(TObject *Sender); 85 | void __fastcall BitHistRedCheckBoxClick(TObject *Sender); 86 | void __fastcall BitsPerColEditKeyPress(TObject *Sender, char &Key); 87 | void __fastcall YBoxesToAnalyzeEditKeyPress(TObject *Sender, char &Key); 88 | private: // User declarations 89 | public: // User declarations 90 | __fastcall TROMBitSettingsForm(TComponent* Owner); 91 | }; 92 | //--------------------------------------------------------------------------- 93 | extern PACKAGE TROMBitSettingsForm *ROMBitSettingsForm; 94 | //--------------------------------------------------------------------------- 95 | #endif 96 | -------------------------------------------------------------------------------- /SelPatFrm.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | #pragma hdrstop 5 | 6 | #include "SelPatFrm.h" 7 | //--------------------------------------------------------------------------- 8 | #pragma package(smart_init) 9 | #pragma resource "*.dfm" 10 | TSelPatForm *SelPatForm; 11 | //--------------------------------------------------------------------------- 12 | __fastcall TSelPatForm::TSelPatForm(TComponent* Owner) 13 | : TForm(Owner) 14 | { 15 | } 16 | //--------------------------------------------------------------------------- 17 | -------------------------------------------------------------------------------- /SelPatFrm.dfm: -------------------------------------------------------------------------------- 1 | object SelPatForm: TSelPatForm 2 | Left = 718 3 | Top = 118 4 | Width = 439 5 | Height = 135 6 | Caption = 'Select pattern' 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'MS Sans Serif' 12 | Font.Style = [] 13 | OldCreateOrder = False 14 | DesignSize = ( 15 | 423 16 | 97) 17 | PixelsPerInch = 96 18 | TextHeight = 13 19 | object Label1: TLabel 20 | Left = 8 21 | Top = 20 22 | Width = 145 23 | Height = 13 24 | Caption = 'Column selection pattern (hex):' 25 | end 26 | object OKBitBtn: TBitBtn 27 | Left = 122 28 | Top = 64 29 | Width = 75 30 | Height = 25 31 | Anchors = [akLeft, akBottom] 32 | TabOrder = 1 33 | Kind = bkOK 34 | end 35 | object CancelBitBtn: TBitBtn 36 | Left = 226 37 | Top = 64 38 | Width = 75 39 | Height = 25 40 | Anchors = [akLeft, akBottom] 41 | TabOrder = 2 42 | Kind = bkCancel 43 | end 44 | object PatEdit: TEdit 45 | Left = 160 46 | Top = 16 47 | Width = 257 48 | Height = 21 49 | Anchors = [akLeft, akTop, akRight] 50 | TabOrder = 0 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /SelPatFrm.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #ifndef SelPatFrmH 4 | #define SelPatFrmH 5 | //--------------------------------------------------------------------------- 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | //--------------------------------------------------------------------------- 12 | class TSelPatForm : public TForm 13 | { 14 | __published: // IDE-managed Components 15 | TBitBtn *OKBitBtn; 16 | TBitBtn *CancelBitBtn; 17 | TEdit *PatEdit; 18 | TLabel *Label1; 19 | private: // User declarations 20 | public: // User declarations 21 | __fastcall TSelPatForm(TComponent* Owner); 22 | }; 23 | //--------------------------------------------------------------------------- 24 | extern PACKAGE TSelPatForm *SelPatForm; 25 | //--------------------------------------------------------------------------- 26 | #endif 27 | -------------------------------------------------------------------------------- /binary.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SiliconAnalysis/bitract/733654f9d350db0b065dee2dc268953a9c308118/binary.ico -------------------------------------------------------------------------------- /bitract.bpr: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | [Version Info] 63 | IncludeVerInfo=0 64 | AutoIncBuild=0 65 | MajorVer=1 66 | MinorVer=0 67 | Release=0 68 | Build=0 69 | Debug=0 70 | PreRelease=0 71 | Special=0 72 | Private=0 73 | DLL=0 74 | Locale=1040 75 | CodePage=1252 76 | 77 | [Version Info Keys] 78 | CompanyName= 79 | FileDescription= 80 | FileVersion=1.0.0.0 81 | InternalName= 82 | LegalCopyright= 83 | LegalTrademarks= 84 | OriginalFilename= 85 | ProductName= 86 | ProductVersion=1.0.0.0 87 | Comments= 88 | 89 | [HistoryLists\hlIncludePath] 90 | Count=4 91 | Item0=C:\Program Files\Borland\CBuilder6\Projects;C:\Program Files\HiComponents\CImageEn6\BCB6;$(BCB)\include;$(BCB)\include\vcl;C:\Program Files (x86)\HiComponents\CImageEn6\BCB6 92 | Item1=C:\Program Files\Borland\CBuilder6\Projects;C:\Program Files\HiComponents\CImageEn6\BCB6;$(BCB)\include;$(BCB)\include\vcl 93 | Item2=C:\Program Files\HiComponents\CImageEn6\BCB6;$(BCB)\include;$(BCB)\include\vcl 94 | Item3=C:\Sviluppo\ImageEn\CBuilder6;C:\Programmi\Borland\CBuilder6\Projects;C:\Documents and Settings\hicomponents\Desktop\directshow;$(BCB)\include;$(BCB)\include\vcl 95 | 96 | [HistoryLists\hlLibraryPath] 97 | Count=4 98 | Item0=C:\Program Files\Borland\CBuilder6\Projects;C:\Program Files\HiComponents\CImageEn6\BCB6;$(BCB)\lib\obj;$(BCB)\lib;C:\Program Files (x86)\HiComponents\CImageEn6\BCB6 99 | Item1=C:\Program Files\Borland\CBuilder6\Projects;C:\Program Files\HiComponents\CImageEn6\BCB6;$(BCB)\lib\obj;$(BCB)\lib 100 | Item2=C:\Program Files\HiComponents\CImageEn6\BCB6;$(BCB)\lib\obj;$(BCB)\lib 101 | Item3=C:\Programmi\Borland\CBuilder6\Projects;C:\Documents and Settings\hicomponents\Desktop\directshow;C:\Sviluppo\ImageEn\CBuilder6;$(BCB)\lib\obj;$(BCB)\lib 102 | 103 | [HistoryLists\hlDebugSourcePath] 104 | Count=1 105 | Item0=$(BCB)\source\vcl 106 | 107 | [HistoryLists\hlConditionals] 108 | Count=1 109 | Item0=_DEBUG 110 | 111 | [Debugging] 112 | DebugSourceDirs=$(BCB)\source\vcl 113 | 114 | [Parameters] 115 | RunParams= 116 | Launcher= 117 | UseLauncher=0 118 | DebugCWD= 119 | HostApplication= 120 | RemoteHost= 121 | RemotePath= 122 | RemoteLauncher= 123 | RemoteCWD= 124 | RemoteDebug=0 125 | 126 | [Compiler] 127 | ShowInfoMsgs=0 128 | LinkDebugVcl=0 129 | LinkCGLIB=0 130 | 131 | [Language] 132 | ActiveLang= 133 | ProjectLang= 134 | RootDir= 135 | 136 | -------------------------------------------------------------------------------- /bitract.cpp: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------- 2 | 3 | #include 4 | 5 | #pragma hdrstop 6 | //--------------------------------------------------------------------------- 7 | USEFORM("LogFrm.cpp", LogForm); 8 | USEFORM("ImageFrm.cpp", ImageForm); 9 | USEFORM("HistogramFrm.cpp", HistogramForm); 10 | USEFORM("ROMBitSettingsFrm.cpp", ROMBitSettingsForm); 11 | //--------------------------------------------------------------------------- 12 | WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) 13 | { 14 | try 15 | { 16 | Application->Initialize(); 17 | 18 | Application->Title = "Bitract: The ROM Bit Extraction System"; 19 | Application->CreateForm(__classid(TLogForm), &LogForm); 20 | Application->CreateForm(__classid(TROMBitSettingsForm), &ROMBitSettingsForm); 21 | Application->CreateForm(__classid(TImageForm), &ImageForm); 22 | Application->CreateForm(__classid(THistogramForm), &HistogramForm); 23 | Application->Run(); 24 | } 25 | catch (Exception &exception) 26 | { 27 | Application->ShowException(&exception); 28 | } 29 | catch (...) 30 | { 31 | try 32 | { 33 | throw Exception(""); 34 | } 35 | catch (Exception &exception) 36 | { 37 | Application->ShowException(&exception); 38 | } 39 | } 40 | return 0; 41 | } 42 | //--------------------------------------------------------------------------- 43 | -------------------------------------------------------------------------------- /bitract.ini: -------------------------------------------------------------------------------- 1 | [ROMPolygon] 2 | 0x=100 3 | 0y=100 4 | 1x=200 5 | 1y=100 6 | 2x=200 7 | 2y=200 8 | 3x=100 9 | 3y=200 10 | [HistogramForm] 11 | Top=534 12 | Left=-1 13 | Width=459 14 | Height=146 15 | [ImageForm] 16 | Top=0 17 | Left=555 18 | Width=726 19 | Height=639 20 | [Image] 21 | WorkingDir= 22 | Filename= 23 | [BitSettings] 24 | BitColumns=16 25 | BitRows=16 26 | BoxWidth=5 27 | BoxHeight=5 28 | Threshold0=64 29 | Threshold1=96 30 | MinBright1=20 31 | MaxBright0=5 32 | BitAnalysisMethod=0 33 | UseR=1 34 | UseG=1 35 | UseB=1 36 | Dot1Threshold=0 37 | Dot0Threshold=0 38 | RimWidth=1 39 | DotWidth=1 40 | XBoxesToAnalyze= 41 | YBoxesToAnalyze= 42 | [ROMBitSettingsForm] 43 | Top=232 44 | Left=0 45 | Width=632 46 | Height=370 47 | [LogForm] 48 | Top=0 49 | Left=0 50 | Width=632 51 | Height=232 52 | -------------------------------------------------------------------------------- /bitract.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SiliconAnalysis/bitract/733654f9d350db0b065dee2dc268953a9c308118/bitract.res --------------------------------------------------------------------------------