Example #1
0
 // setup an empty memory map, this should be called once
 public void init(int filesize, FrmMain formMainHandle)
 {
     lstBoxLocations.Items.Add("0 \t<start of file>");
     mapMarker[numNotes].set(0, 0, "<start of file>");
     numNotes++;
     lstBoxLocations.Items.Add(filesize.ToString()+"\t<start of file>");
     mapMarker[numNotes].set(filesize, filesize, "<end of file>");
     numNotes++;
     updateDisplay();
     gFrmMain = formMainHandle;
     gFileSize = filesize;
 }
Example #2
0
        public void Plot(ref byte[] fileBufferArray, int fileSize, float[] frequency, int offset, FrmEncode frmEncode, FrmMain frmMain) {
            int columns = pictureBox1.Width;
            int rows = pictureBox1.Height;
            int position = offset;
            byte currentByte;
            globalFrmMain = frmMain;
            globalOffset = offset;
            globalFileSize = fileSize;
            globalColumns = columns;

            Bitmap b = new Bitmap(columns, rows, PixelFormat.Format24bppRgb);
            BitmapData bmd = b.LockBits(new Rectangle(0, 0, columns, rows), ImageLockMode.ReadWrite, b.PixelFormat); //PixelFormat.Format24bppRgb
       
            // The unsafe code block is necessary to operate directly on the image
            // memory vs. setpixel.  About 250-300x faster
            unsafe {
                for (int j = 0; j < rows; j++) {
                    byte* row = (byte*)bmd.Scan0 + (j * bmd.Stride); 
                    
                    for (int i = 0; i < columns; i++) {
                        currentByte = 0;
                        if (position < fileSize) {
                            currentByte = fileBufferArray[j * columns + i + offset];
                            position++;

                            //color coding
                            if (FrmEncode.colorMode == 0) { //normal
                                row[i * 3 + 1] = currentByte;
                            } else if (FrmEncode.colorMode == 1) {//ASCII
                                if ((currentByte >= 32) && (currentByte <= 127)) {
                                    row[i * 3] = 255; //blue
                                } else {
                                    row[i * 3] = 32; //gray
                                    row[i * 3 + 1] = 32;
                                    row[i * 3 + 2] = 32;                                    
                                }

                            } else if (FrmEncode.colorMode == 2) {//Frequency
                                if (frequency[currentByte]>.375){
                                  row[i * 3+2] = 255; //red
                                } 
                                if (frequency[currentByte] <.01) {
                                  row[i * 3] = 255; //blue
                                }

                                if ((frequency[currentByte] >= .01)&&(frequency[currentByte]<=.375))
                                 {
                                    row[i * 3] = 64; //gray
                                    row[i * 3 + 1] = 64;
                                    row[i * 3 + 2] = 64;   
                                }
                            }


                            if (FrmEncode.invert == 1) {
                                row[i * 3] = (byte)(255 - row[i * 3]);
                                row[i * 3 + 1] = (byte)(255 - row[i * 3+1]);
                                row[i * 3 + 2] = (byte)(255 - row[i * 3+2]); 
                            }
                        }                                            
                    }
                }                
                b.UnlockBits(bmd);
                pictureBox1.Image = b;
             
               // Invert(b);
            } //unsafe
    
        }
Example #3
0
 public FrmStrings(FrmMain frmMain)
 {
     InitializeComponent();
     gFrmMain = frmMain;
 }
Example #4
0
 //overide constructor in order to accept argument
 public FrmNavigator(FrmMain callingHandle)
 {
     InitializeComponent(); 
     handle = callingHandle;
 }
Example #5
0
        // internal static void
        public void calcFrequency(int fileLength, ref int[] byteCount, ref byte[] fileBufferArray, ref float[] frequency, FrmMain frmMainHandle)
        {
            FrmProgressBar fpb = new FrmProgressBar("calculating byte frequency...");
            //Console.WriteLine(this.ParentForm.ToString());
            
            fpb.MdiParent = frmMainHandle;
            fpb.Start(0, fileLength);
            fpb.Show();

                for (int i = 0; i < fileLength; i++) {
                    byteCount[fileBufferArray[i]]++;
                    if (i % 10000 == 0)
                    {
                        fpb.Update(i);
                        Application.DoEvents();
                    }
                }
                for (int j = 0; j <= 255; j++) {
                    frequency[j] = (float)byteCount[j] / fileLength; //dividing int by int is integer division, must cast to float
                    //Console.WriteLine(j + " " + byteCount[j]+ " " + fileLength + " " + frequency[j]);
                }
            fpb.Hide();
        }
Example #6
0
 //overide constructor in order to accept argument
 public FrmNavigator(FrmMain callingHandle)
 {
     InitializeComponent();
     handle = callingHandle;
 }
Example #7
0
        // internal static void
        public void calcFrequency(int fileLength, ref int[] byteCount, ref byte[] fileBufferArray, ref float[] frequency, FrmMain frmMainHandle)
        {
            FrmProgressBar fpb = new FrmProgressBar("calculating byte frequency...");

            //Console.WriteLine(this.ParentForm.ToString());

            fpb.MdiParent = frmMainHandle;
            fpb.Start(0, fileLength);
            fpb.Show();

            for (int i = 0; i < fileLength; i++)
            {
                byteCount[fileBufferArray[i]]++;
                if (i % 10000 == 0)
                {
                    fpb.Update(i);
                    Application.DoEvents();
                }
            }
            for (int j = 0; j <= 255; j++)
            {
                frequency[j] = (float)byteCount[j] / fileLength;     //dividing int by int is integer division, must cast to float
                //Console.WriteLine(j + " " + byteCount[j]+ " " + fileLength + " " + frequency[j]);
            }
            fpb.Hide();
        }