private void Make() { this.iLogger.LogMessage("Dragon to UO Landscaper Conversion"); this.iLogger.StartTask(); if (StringType.StrCmp(this.ProjectName.Text, string.Empty, false) == 0) { this.iLogger.LogMessage("Error: Enter a project Name."); } else { this.iLogger.LogMessage("Loading Dragon Image."); try { string str = string.Format("{0}\\{1}", (object)this.DragonPath.Text, (object)this.DragonImage.Text); this.iLogger.LogMessage(str); this.i_Dragon = new Bitmap(str); } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception exception = ex; this.iLogger.LogMessage("Problem with Loading Dragon Image."); this.iLogger.LogMessage(exception.Message); ProjectData.ClearProjectError(); return; } this.iLogger.LogMessage("Preparing Dragon Image."); int width = this.i_Dragon.Width; int height = this.i_Dragon.Height; Rectangle rect = new Rectangle(0, 0, width, height); BitmapData bitmapData = this.i_Dragon.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed); IntPtr scan0_1 = bitmapData.Scan0; int length1 = checked (bitmapData.Width * bitmapData.Height); byte[] destination = new byte[checked (length1 - 1 + 1)]; Marshal.Copy(scan0_1, destination, 0, length1); Bitmap bitmap1 = new Bitmap(width, height, PixelFormat.Format8bppIndexed); BitmapData bitmapdata1 = bitmap1.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed); IntPtr scan0_2 = bitmapdata1.Scan0; int length2 = checked (bitmapdata1.Width * bitmapdata1.Height); byte[] numArray1 = new byte[checked (length2 - 1 + 1)]; Marshal.Copy(scan0_2, numArray1, 0, length2); Bitmap bitmap2 = new Bitmap(width, height, PixelFormat.Format8bppIndexed); BitmapData bitmapdata2 = bitmap2.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed); IntPtr scan0_3 = bitmapdata2.Scan0; int length3 = checked (bitmapdata2.Width * bitmapdata2.Height); byte[] numArray2 = new byte[checked (length3 - 1 + 1)]; Marshal.Copy(scan0_3, numArray2, 0, length3); this.iAltitude.Load(); this.iTerrain.Load(); TransInfo transInfo = (TransInfo)this.ComboBox1.SelectedItem; if (transInfo == null) { this.iLogger.LogMessage("Error: Please select which dragon mod to convert from."); } else { this.iDragon.Load(string.Format("{0}{1}", (object)AppDomain.CurrentDomain.BaseDirectory, (object)transInfo.Location)); this.ProgressBar1.Maximum = checked (length1 - 1); int num1 = 0; int num2 = checked (length1 - 1); int index = num1; while (index <= num2) { byte num3 = destination[index]; ClsDragon clsDragon = this.iDragon.get_GetDragon((int)num3); if (clsDragon != null) { numArray2[index] = clsDragon.AltitudeID; numArray1[index] = clsDragon.TerrainID; } else { this.iLogger.LogMessage(string.Format("Loc:{0} Color:{1}", (object)index, (object)num3)); numArray2[index] = (byte)0; numArray1[index] = (byte)0; } this.ProgressBar1.Value = index; checked { ++index; } } Marshal.Copy(numArray2, 0, scan0_3, length3); bitmap2.UnlockBits(bitmapdata2); Marshal.Copy(numArray1, 0, scan0_2, length2); bitmap1.UnlockBits(bitmapdata1); string path = string.Format("{0}/{1}/Dragon", (object)this.ProjectPath.Text, (object)this.ProjectName.Text); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string filename1 = string.Format("{0}/{1}", (object)path, (object)this.TerrainFile.Text); this.iTerrain.Load(); bitmap1.Palette = this.iTerrain.GetPalette(); bitmap1.Save(filename1, ImageFormat.Bmp); bitmap1.Dispose(); string filename2 = string.Format("{0}/{1}", (object)path, (object)this.AltitudeFile.Text); this.iAltitude.Load(); bitmap2.Palette = this.iAltitude.GetAltPalette(); bitmap2.Save(filename2, ImageFormat.Bmp); bitmap2.Dispose(); this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Done."); } } }
private void Make() { this.iLogger.LogMessage("Dragon to UO Landscaper Conversion"); this.iLogger.StartTask(); if (StringType.StrCmp(this.ProjectName.get_Text(), string.Empty, false) != 0) { this.iLogger.LogMessage("Loading Dragon Image."); try { string str = string.Format("{0}\\{1}", this.DragonPath.get_Text(), this.DragonImage.get_Text()); this.iLogger.LogMessage(str); this.i_Dragon = new Bitmap(str); } catch (Exception exception1) { ProjectData.SetProjectError(exception1); Exception exception = exception1; this.iLogger.LogMessage("Problem with Loading Dragon Image."); this.iLogger.LogMessage(exception.get_Message()); ProjectData.ClearProjectError(); return; } this.iLogger.LogMessage("Preparing Dragon Image."); int width = this.i_Dragon.get_Width(); int height = this.i_Dragon.get_Height(); Rectangle rectangle = new Rectangle(0, 0, width, height); BitmapData bitmapDatum = this.i_Dragon.LockBits(rectangle, 3, 198659); IntPtr scan0 = bitmapDatum.get_Scan0(); int num = checked (bitmapDatum.get_Width() * bitmapDatum.get_Height()); byte[] numArray = new byte[checked (checked (num - 1) + 1)]; Marshal.Copy(scan0, numArray, 0, num); Bitmap bitmap = new Bitmap(width, height, 198659); BitmapData bitmapDatum1 = bitmap.LockBits(rectangle, 3, 198659); IntPtr intPtr = bitmapDatum1.get_Scan0(); int width1 = checked (bitmapDatum1.get_Width() * bitmapDatum1.get_Height()); byte[] terrainID = new byte[checked (checked (width1 - 1) + 1)]; Marshal.Copy(intPtr, terrainID, 0, width1); Bitmap bitmap1 = new Bitmap(width, height, 198659); BitmapData bitmapDatum2 = bitmap1.LockBits(rectangle, 3, 198659); IntPtr scan01 = bitmapDatum2.get_Scan0(); int num1 = checked (bitmapDatum2.get_Width() * bitmapDatum2.get_Height()); byte[] altitudeID = new byte[checked (checked (num1 - 1) + 1)]; Marshal.Copy(scan01, altitudeID, 0, num1); this.iAltitude.Load(); this.iTerrain.Load(); TransInfo selectedItem = (TransInfo)this.ComboBox1.get_SelectedItem(); if (selectedItem != null) { string str1 = string.Format("{0}{1}", AppDomain.get_CurrentDomain().get_BaseDirectory(), selectedItem.Location); this.iDragon.Load(str1); this.ProgressBar1.set_Maximum(checked (num - 1)); int num2 = checked (num - 1); for (int i = 0; i <= num2; i++) { byte num3 = numArray[i]; ClsDragon getDragon = this.iDragon[num3]; if (getDragon == null) { this.iLogger.LogMessage(string.Format("Loc:{0} Color:{1}", i, num3)); altitudeID[i] = 0; terrainID[i] = 0; } else { altitudeID[i] = getDragon.AltitudeID; terrainID[i] = getDragon.TerrainID; } this.ProgressBar1.set_Value(i); } Marshal.Copy(altitudeID, 0, scan01, num1); bitmap1.UnlockBits(bitmapDatum2); Marshal.Copy(terrainID, 0, intPtr, width1); bitmap.UnlockBits(bitmapDatum1); string str2 = string.Format("{0}/{1}/Dragon", this.ProjectPath.get_Text(), this.ProjectName.get_Text()); if (!Directory.Exists(str2)) { Directory.CreateDirectory(str2); } string str3 = string.Format("{0}/{1}", str2, this.TerrainFile.get_Text()); this.iTerrain.Load(); bitmap.set_Palette(this.iTerrain.GetPalette()); bitmap.Save(str3, ImageFormat.get_Bmp()); bitmap.Dispose(); str3 = string.Format("{0}/{1}", str2, this.AltitudeFile.get_Text()); this.iAltitude.Load(); bitmap1.set_Palette(this.iAltitude.GetAltPalette()); bitmap1.Save(str3, ImageFormat.get_Bmp()); bitmap1.Dispose(); this.iLogger.EndTask(); this.iLogger.LogTimeStamp(); this.iLogger.LogMessage("Done."); } else { this.iLogger.LogMessage("Error: Please select which dragon mod to convert from."); } } else { this.iLogger.LogMessage("Error: Enter a project Name."); } }