public static Bitmap Split(byte[] bytes, int count) { Bitmap bmp = new Bitmap(ConvertImageByteArray.ByteArrayToImage(bytes)); Bitmap cloneBmp = new Bitmap(1, bmp.Height); Graphics gr = Graphics.FromImage(cloneBmp); gr.DrawImage(bmp, new Rectangle(0, 0, 1, bmp.Height), new Rectangle(count, 0, count + 1, bmp.Height), GraphicsUnit.Pixel); bmp.Dispose(); gr.Dispose(); return(cloneBmp); }
private void ProcessImages(object stateObj) { object[] state = (object[])stateObj; //SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID((int)state[0]))); //if ((int)state[0] == 0 || (int)state[0] == 1) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(0))); //} //else if ((int)state[0] == 2 || (int)state[0] == 3) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(1))); //} //else if ((int)state[0] == 4 || (int)state[0] == 5) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(2))); //} //else if ((int)state[0] == 6 || (int)state[0] == 7) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(3))); //} //else if ((int)state[0] == 8 || (int)state[0] == 9) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(4))); //} //else if ((int)state[0] == 10 || (int)state[0] == 11) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(5))); //} //else if ((int)state[0] == 12 || (int)state[0] == 13) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(6))); //} //else if ((int)state[0] == 14 || (int)state[0] == 15) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(7))); //} //else if ((int)state[0] == 16 || (int)state[0] == 17) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(8))); //} //else if ((int)state[0] == 18 || (int)state[0] == 19) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(9))); //} //else if ((int)state[0] == 20 || (int)state[0] == 21) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(10))); //} //else if ((int)state[0] == 22 || (int)state[0] == 23) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(11))); //} //else if ((int)state[0] == 24 || (int)state[0] == 25) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(12))); //} //else if ((int)state[0] == 26 || (int)state[0] == 27) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(13))); //} //else if ((int)state[0] == 28 || (int)state[0] == 29) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(14))); //} //else if ((int)state[0] == 30 || (int)state[0] == 31) //{ // SetThreadAffinityMask(GetCurrentThread(), new UIntPtr(SetCpuID(15))); //} int taskNum = 0; if (radioButton1.Checked && !radioButton2.Checked) { taskNum = 64; } else if (!radioButton1.Checked && radioButton2.Checked) { taskNum = 32; } for (int i = (int)state[0] * taskNum; i <= (int)state[0] * taskNum + taskNum - 1; i++) { bmp[i] = new List <Bitmap>(); //set a base image for merging Image img = ConvertImageByteArray.ByteArrayToImage(_imageArray[0]); for (int startPoint = 0; startPoint < (int)state[1]; startPoint++) { //store columns in list bmp[i].Add(SplitMerge.Split(_imageArray[startPoint], i)); //Update interface lable.text try { this.Invoke(UpdateDelegate, new object[] { true, string.Empty }); } catch { } } // merge , bmp[i] will be the base and will be cleaned SplitMerge.Merge(bmp[i], img).Save(string.Format(_saveFileLocation, i)); //Update interface lable.text try { this.Invoke(UpdateDelegate, new object[] { false, string.Format(_saveFileLocation, i) }); } catch { } // clear list to release memory bmp[i] = null; } }