public ActionResult GumpArt(int id, int hue = 0) { DeleteTempFiles(System.Web.HttpContext.Current); Files.SetMulPath(HttpContext.Server.MapPath("~/mul")); Bitmap bmp; if (hue > 0 && hue <= 3000) { bool patched; bmp = new Bitmap(Gumps.GetGump(id, Hues.GetHue(hue), false, out patched)); } else { bmp = new Bitmap(Gumps.GetGump(id)); } byte[] byteArray = ImageToByte(bmp); using (Image image = Image.FromStream(new MemoryStream(byteArray))) { image.Save(HttpContext.Server.MapPath("~/tempfiles/") + id + hue + ".png", ImageFormat.Png); } ViewBag.img = "/tempfiles/" + id + hue + ".png"; return(File(HttpContext.Server.MapPath("~/tempfiles/") + id + hue + ".png", "image/png")); }
public override void RefreshCache() { if (this.ImageCache != null) { this.ImageCache.Dispose(); } this.ImageCache = Gumps.GetGump(this.mGumpID); if (this.ImageCache == null) { this.GumpID = 0; } if (this.mHue.Index != 0) { this.mHue.ApplyTo(this.ImageCache, false); } try { if (this.ImageCache != null && !this.ImageCache.Size.IsEmpty) { this.mTileSize = this.ImageCache.Size; } } catch (Exception ex) { } }
private void lstGump_DrawItem(object sender, DrawItemEventArgs e) { try { if (e.Index == -1) { return; } Size size1 = new Size(); Graphics graphics = e.Graphics; Bitmap gump = Gumps.GetGump(GumpArtBrowser.Cache[e.Index].ID); Size size2 = GumpArtBrowser.Cache[e.Index].Size; size1.Width = size2.Width <= 100 ? size2.Width : 100; size1.Height = size2.Height <= 100 ? size2.Height : 100; Rectangle rect = new Rectangle(e.Bounds.Location, size1); rect.Offset(45, 3); if ((e.State & DrawItemState.Selected) > DrawItemState.None) { graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds); } else { graphics.FillRectangle(SystemBrushes.Window, e.Bounds); } graphics.DrawString("0x" + GumpArtBrowser.Cache[e.Index].ID.ToString("X"), this.Font, SystemBrushes.WindowText, (float)e.Bounds.X, (float)e.Bounds.Y); graphics.DrawImage((Image)gump, rect); gump.Dispose(); } catch (Exception ex) { ProjectData.SetProjectError(ex); int num = (int)Interaction.MsgBox((object)("There was an error rendering the gump art, try rebuilding the cache.\r\n\r\n" + ex.Message), MsgBoxStyle.OkOnly, (object)null); ProjectData.ClearProjectError(); } }
private void OnClick_SaveAllJpg(object sender, EventArgs e) { using (FolderBrowserDialog dialog = new FolderBrowserDialog()) { dialog.Description = "Select directory"; dialog.ShowNewFolderButton = true; if (dialog.ShowDialog() == DialogResult.OK) { for (int i = 0; i < listBox.Items.Count; ++i) { int index = int.Parse(listBox.Items[i].ToString()); if (index >= 0) { string FileName = Path.Combine(dialog.SelectedPath, String.Format("Gump {0}.jpg", index)); Bitmap bit = new Bitmap(Gumps.GetGump(index)); if (bit != null) { bit.Save(FileName, ImageFormat.Jpeg); } bit.Dispose(); } } MessageBox.Show(String.Format("All Gumps saved to {0}", dialog.SelectedPath), "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } } }
private void listBox_SelectedIndexChanged(object sender, EventArgs e) { if (listBox.SelectedIndex == -1) { return; } int i = int.Parse(listBox.Items[listBox.SelectedIndex].ToString()); if (Gumps.IsValidIndex(i)) { Bitmap bmp = Gumps.GetGump(i); if (bmp != null) { pictureBox.BackgroundImage = bmp; IDLabel.Text = String.Format("ID: 0x{0:X} ({1})", i, i); SizeLabel.Text = String.Format("Size: {0},{1}", bmp.Width, bmp.Height); } else { pictureBox.BackgroundImage = null; } } else { pictureBox.BackgroundImage = null; } listBox.Invalidate(); jumpToMaleFemaleInvalidate(); }
private void lstGump_DrawItem(object sender, DrawItemEventArgs e) { try { if (e.Index == -1) { return; } Size size1 = new Size(); Graphics graphics = e.Graphics; Bitmap gump = Gumps.GetGump(Cache[e.Index].ID); Size size2 = Cache[e.Index].Size; size1.Width = size2.Width <= 100 ? size2.Width : 100; size1.Height = size2.Height <= 100 ? size2.Height : 100; Rectangle rect = new Rectangle(e.Bounds.Location, size1); rect.Offset(45, 3); graphics.FillRectangle((e.State & DrawItemState.Selected) > DrawItemState.None ? SystemBrushes.Highlight : SystemBrushes.Window, e.Bounds); graphics.DrawString("0x" + Cache[e.Index].ID.ToString("X"), Font, SystemBrushes.WindowText, e.Bounds.X, e.Bounds.Y); graphics.DrawImage(gump, rect); gump.Dispose(); } catch (Exception ex) { MessageBox.Show(@"There was an error rendering the gump art, try rebuilding the cache.\r\n\r\n" + ex.Message); } }
private void ListBox_SelectedIndexChanged(object sender, EventArgs e) { if (listBox.SelectedIndex == -1) { return; } int i = int.Parse(listBox.Items[listBox.SelectedIndex].ToString()); if (Gumps.IsValidIndex(i)) { Bitmap bmp = Gumps.GetGump(i); if (bmp != null) { pictureBox.BackgroundImage = bmp; IDLabel.Text = $"ID: 0x{i:X} ({i})"; SizeLabel.Text = $"Size: {bmp.Width},{bmp.Height}"; } else { pictureBox.BackgroundImage = null; } } else { pictureBox.BackgroundImage = null; } listBox.Invalidate(); JumpToMaleFemaleInvalidate(); }
public override void RefreshCache() { if (this.Image1Cache != null) { this.Image1Cache.Dispose(); } if (this.Image2Cache != null) { this.Image1Cache.Dispose(); } this.Image1Cache = (Image)Gumps.GetGump(this.mUncheckedID); if (this.Image1Cache == null) { this.UnCheckedID = 210; } this.Image2Cache = (Image)Gumps.GetGump(this.mCheckedID); if (this.Image2Cache == null) { this.CheckedID = 211; } if (this.mChecked) { this.mSize = this.Image2Cache.Size; } else { this.mSize = this.Image1Cache.Size; } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { var gumpArtBrowser = new GumpArtBrowser { GumpID = Conversions.ToInteger(value) }; if (edSvc.ShowDialog(gumpArtBrowser) == DialogResult.OK) { Image gump = Gumps.GetGump(gumpArtBrowser.GumpID); if (gump != null) { gump.Dispose(); ReturnValue = gumpArtBrowser.GumpID; gumpArtBrowser.Dispose(); return(ReturnValue); } MessageBox.Show("Invalid GumpID"); return(value); } gumpArtBrowser.Dispose(); } return(value); }
private void PreLoaderDoWork(object sender, DoWorkEventArgs e) { for (int i = 0; i < Gumps.GetCount(); ++i) { Gumps.GetGump(i); PreLoader.ReportProgress(1); } }
/// <summary> /// Calculates the image displayed by the control /// </summary> private void CreateDisplay() { if (m_Image != null) { m_Image.Dispose(); } switch (m_Art) { case Art.Items: try { m_Image = new Bitmap(TheBox.UltimaImport.Art.GetStatic(m_ArtIndex)); } catch { m_Image = null; } break; case Art.Gumps: try { m_Image = new Bitmap(Gumps.GetGump(m_ArtIndex)); } catch { m_Image = null; } break; case Art.NPCs: if (m_Animate) { m_Image = DoAnimation(); } else { Frame[] frames = Animations.GetAnimation(m_ArtIndex, 0, 1, 0, true); if (frames != null) { m_Image = new Bitmap(frames[0].Bitmap); } else { m_Image = null; } } break; } // Hue if (m_Hue != 0 && m_Image != null && m_Art != Art.Images) { if (m_Art != Art.NPCs || m_Art == Art.NPCs && !m_Animate) { // Use m_Hue - 1 because hues are zero based, while the game considers them 1-based TheBox.UltimaImport.Hue.ApplyHueTo(m_Hue - 1, m_Image, false); } } }
private void lstGump_SelectedIndexChanged(object sender, EventArgs e) { if (this.picFullSize.Image != null) { this.picFullSize.Image.Dispose(); } this.picFullSize.Image = (Image)Gumps.GetGump(Conversions.ToInteger(this.lstGump.SelectedItem)); this.lblSize.Text = "Width: " + Conversions.ToString(this.picFullSize.Image.Width) + " Height: " + Conversions.ToString(this.picFullSize.Image.Height); }
public override void RefreshCache() { this.imgUp = Gumps.GetGump(250); this.imgDown = Gumps.GetGump(252); this.imgLoc = Gumps.GetGump(254); this.imgBack = Gumps.GetGump(256); this.mBGElement = new BackgroundElement(); this.mBGElement.GumpID = 3000; }
protected void BuildCache() { this.lblWait.Text = "Please Wait, Generating Art Cache..."; this.Show(); GumpArtBrowser.Cache = (GumpCacheEntry[])null; this.lstGump.Items.Clear(); this.lblWait.Visible = true; Application.DoEvents(); int index = 0; int maxValue = (int)ushort.MaxValue; try { do { this.lblWait.Text = "Please Wait, Generating Art Cache... " + Strings.Format((object)(int)((double)(100 * index) / (double)maxValue), "Fixed") + "%"; Application.DoEvents(); Bitmap gump; try { gump = Gumps.GetGump(index); } catch (Exception ex) { ++index; continue; } if (gump != null) { GumpArtBrowser.Cache = GumpArtBrowser.Cache != null ? (GumpCacheEntry[])Utils.CopyArray((Array)GumpArtBrowser.Cache, (Array) new GumpCacheEntry[GumpArtBrowser.Cache.Length + 1]) : new GumpCacheEntry[1]; GumpArtBrowser.Cache[GumpArtBrowser.Cache.Length - 1] = new GumpCacheEntry(); GumpArtBrowser.Cache[GumpArtBrowser.Cache.Length - 1].ID = index; GumpArtBrowser.Cache[GumpArtBrowser.Cache.Length - 1].Size = gump.Size; gump.Dispose(); } ++index; }while (index <= maxValue); using (FileStream fileStream = new FileStream(Application.StartupPath + "/GumpArt.cache", FileMode.Create)) new BinaryFormatter().Serialize((Stream)fileStream, (object)GumpArtBrowser.Cache); } catch (Exception ex) { ProjectData.SetProjectError(ex); int num = (int)Interaction.MsgBox((object)("Error creating cache file:\r\n" + ex.Message), MsgBoxStyle.OkOnly, (object)null); ProjectData.ClearProjectError(); } finally { this.lblWait.Visible = false; Application.DoEvents(); } }
//http://wpdev.sourceforge.net/docs/formats/csharp/art.html //https://uo.stratics.com/heptazane/fileformats.shtml#3.3 static void Main(string[] args) { Stopwatch w = Stopwatch.StartNew(); FileManager.UoFolderPath = @"E:\Giochi\Ultima Online Classic ORION"; FileManager.LoadFiles(); Map.Malas.Load(); var aadwa = Map.Malas.Tiles.GetLandTile(944 >> 8, 480 >> 8); ushort[] pixels = Art.ReadStaticArt(0x206A, out short width, out short height); ushort[] landpixels = Art.ReadLandArt(3); GraphicHelper.HasBody(46); int hue = 38; // 1254 = wild tiger //var animation = Animations.GetAnimation(1421, 0, 0, ref hue); /*var animation1 = Animations.GetAnimation(1253, 0, 0, ref hue); * var animation2 = Animations.GetAnimation(1250, 0, 0, ref hue);*/ var a = Fonts.GetASCII(0).GetChar('A'); ushort[] pixelsgump = Gumps.GetGump(0x1393, out int widthgump, out int heightgump); Map.Felucca.Load(); int x = 1201; int y = 1694; for (int i = 0, oy = y; i < 10; i++, oy++) { for (int j = 0, ox = x; j < 10; j++, ox++) { var aa = Map.Felucca.GetRenderedBlock(ox, oy, 24, 24); } } Map.Felucca.Unload(); Map.Malas.Load(); x = 644; y = 480; var aaa = Map.Malas.GetRenderedBlock(x, y, 24, 24); // MultiComponentList components = Multi.GetMulti(50); var skill = Skills.GetSkill(2); Console.WriteLine(w.ElapsedMilliseconds + " ms"); Console.ReadLine(); }
private void Listbox1_DrawItem(object sender, DrawItemEventArgs e) { ListBox listBox = (ListBox)sender; if (e.Index < 0) { return; } Brush fontBrush = Brushes.Gray; int i = (int)listBox.Items[e.Index]; if (listBox.SelectedIndex == e.Index) { e.Graphics.FillRectangle(Brushes.LightSteelBlue, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); } bool valid = (int)listBox.Tag == 1 ? Gumps.IsValidIndex(i) : SecondGump.IsValidIndex(i); if (valid) { Bitmap bmp = (int)listBox.Tag == 1 ? Gumps.GetGump(i) : SecondGump.GetGump(i); if (bmp != null) { if (listBox2.Items.Count > 0) { if (!Compare(i)) { fontBrush = Brushes.Blue; } } int width = bmp.Width > 80 ? 80 : bmp.Width; int height = bmp.Height > 54 ? 54 : bmp.Height; e.Graphics.DrawImage(bmp, new Rectangle(e.Bounds.X + 3, e.Bounds.Y + 3, width, height)); } else { fontBrush = Brushes.Red; } } else { fontBrush = Brushes.Red; } e.Graphics.DrawString($"0x{i:X}", Font, fontBrush, new PointF(85, e.Bounds.Y + ((e.Bounds.Height / 2) - (e.Graphics.MeasureString($"0x{i:X}", Font).Height / 2)))); }
public static Size GetGumpSize(int gumpID) { lock (syncRoot) { Bitmap bitmap; if (!gumpCache.TryGetValue(gumpID, out bitmap)) { bitmap = Gumps.GetGump(gumpID); gumpCache.Add(gumpID, bitmap); } return(bitmap == null ? Size.Empty : bitmap.Size); } }
public static Bitmap GetGump(int gumpID) { lock (syncRoot) { Bitmap bitmap; if (!gumpCache.TryGetValue(gumpID, out bitmap)) { bitmap = Gumps.GetGump(gumpID); gumpCache.Add(gumpID, bitmap); } return(bitmap); } }
public override void RefreshCache() { if (this.Cache != null) { this.Cache.Dispose(); } this.Cache = this.mState != ButtonStateEnum.Normal ? Gumps.GetGump(this.mPressedID) : Gumps.GetGump(this.mNormalID); if (this.Cache == null) { return; } this.mSize = this.Cache.Size; }
private void ListBox_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index < 0) { return; } Brush fontBrush = _brushGray; int i = int.Parse(listBox.Items[e.Index].ToString()); if (Gumps.IsValidIndex(i)) { Bitmap bmp = Gumps.GetGump(i, out bool patched); if (bmp != null) { int width = bmp.Width > 100 ? 100 : bmp.Width; int height = bmp.Height > 54 ? 54 : bmp.Height; if (listBox.SelectedIndex == e.Index) { e.Graphics.FillRectangle(_brushLightSteelBlue, e.Bounds.X, e.Bounds.Y, 105, 60); } else if (patched) { e.Graphics.FillRectangle(_brushLightCoral, e.Bounds.X, e.Bounds.Y, 105, 60); } e.Graphics.DrawImage(bmp, new Rectangle(e.Bounds.X + 3, e.Bounds.Y + 3, width, height)); } else { fontBrush = _brushRed; } } else { if (listBox.SelectedIndex == e.Index) { e.Graphics.FillRectangle(_brushLightSteelBlue, e.Bounds.X, e.Bounds.Y, 105, 60); } fontBrush = _brushRed; } e.Graphics.DrawString($"0x{i:X} ({i})", Font, fontBrush, new PointF(105, e.Bounds.Y + ((e.Bounds.Height / 2) - (e.Graphics.MeasureString($"0x{i:X} ({i})", Font).Height / 2)))); }
public override void RefreshCache() { if (this.ImageCache != null) { this.ImageCache.Dispose(); } this.ImageCache = Gumps.GetGump(this.mGumpID); if (this.ImageCache == null) { this.GumpID = 0; } if (this.mHue.Index != 0) { this.mHue.ApplyTo(this.ImageCache, false); } this.mSize = this.ImageCache.Size; }
private void onKeyDownGump(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { int index; if (Utils.ConvertStringToInt(TextBoxGump.Text, out index, 0, 0xFFFE)) { if (!Gumps.IsValidIndex(index)) { return; } contextMenuStrip1.Close(); preview = Gumps.GetGump(index); RefreshPreview(); } } }
private void extract_Image_ClickJpg(object sender, EventArgs e) { string path = FiddlerControls.Options.OutputPath; int i = int.Parse(listBox.Items[listBox.SelectedIndex].ToString()); string FileName = Path.Combine(path, String.Format("Gump {0}.jpg", i)); Bitmap bit = new Bitmap(Gumps.GetGump(i)); if (bit != null) { bit.Save(FileName, ImageFormat.Jpeg); } bit.Dispose(); MessageBox.Show( String.Format("Gump saved to {0}", FileName), "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); }
private void extract_Image_ClickTiff(object sender, EventArgs e) { string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; int i = int.Parse(listBox.Items[listBox.SelectedIndex].ToString()); string FileName = Path.Combine(path, String.Format("Gump {0}.tiff", i)); Bitmap bit = new Bitmap(Gumps.GetGump(i)); if (bit != null) { bit.Save(FileName, ImageFormat.Tiff); } bit.Dispose(); MessageBox.Show( String.Format("Gump saved to {0}", FileName), "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); }
public override void RefreshCache() { if (this.mMultImageCache == null) { this.mMultImageCache = new Image[9]; } int index = 0; int num; do { if (this.mMultImageCache[index] != null) { this.mMultImageCache[index].Dispose(); } this.mMultImageCache[index] = (Image)Gumps.GetGump(index + this.mGumpID); ++index; num = 8; }while (index <= num); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { this.edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (this.edSvc != null) { GumpArtBrowser gumpArtBrowser = new GumpArtBrowser(); gumpArtBrowser.GumpID = Conversions.ToInteger(value); if (this.edSvc.ShowDialog((Form)gumpArtBrowser) == DialogResult.OK) { Image gump = (Image)Gumps.GetGump(gumpArtBrowser.GumpID); if (gump != null) { gump.Dispose(); this.ReturnValue = gumpArtBrowser.GumpID; gumpArtBrowser.Dispose(); return((object)this.ReturnValue); } int num = (int)Interaction.MsgBox((object)"invalid GumpID", MsgBoxStyle.OkOnly, (object)null); return(value); } gumpArtBrowser.Dispose(); } return(value); }
/// <summary> /// Calculates the image displayed by the control /// </summary> private void CreateDisplay() { if (m_Image != null) { m_Image.Dispose(); } switch (m_Art) { case Art.Items: try { m_Image = new Bitmap(Ultima.Art.GetStatic(m_ArtIndex)); } catch { m_Image = null; } break; case Art.Gumps: try { m_Image = new Bitmap(Gumps.GetGump(m_ArtIndex)); } catch { m_Image = null; } break; case Art.NPCs: try { if (m_Animate) { m_Image = DoAnimation(); } else { var hue = m_Hue; var frames = Animations.GetAnimation(m_ArtIndex, 0, 1, ref hue, true, true); if (frames != null) { m_Image = new Bitmap(frames[0].Bitmap); } else { m_Image = null; } } } catch { m_Image = null; } break; } // // Hue // if (m_Hue > 0 && m_Image != null && m_Art != Art.Images) { if (m_Art != Art.NPCs || (m_Art == Art.NPCs && !m_Animate)) { var hue = Hues.GetHue(m_Hue - 1); if (hue != null) { Hues.ApplyTo(m_Image, hue.Colors, m_Art == Art.Gumps); } } } }
private void lstGump_SelectedIndexChanged(object sender, EventArgs e) { _picFullSize.Image?.Dispose(); _picFullSize.Image = Gumps.GetGump(Convert.ToInt32(_lstGump.SelectedItem)); _lblSize.Text = @"Width: " + Convert.ToString(_picFullSize.Image.Width) + @" Height: " + Convert.ToString(_picFullSize.Image.Height); }
private void listbox_SelectedChange(object sender, EventArgs e) { ListBox listBox = (ListBox)sender; if (listBox.SelectedIndex == -1) { return; } int i = (int)listBox.Items[listBox.SelectedIndex]; bool valid; if ((int)listBox.Tag == 1) { valid = Gumps.IsValidIndex(i); if (listBox2.Items.Count > 0) { listBox2.SelectedIndex = listBox2.Items.IndexOf(i); } } else { valid = SecondGump.IsValidIndex(i); listBox1.SelectedIndex = listBox1.Items.IndexOf(i); } if (valid) { Bitmap bmp; if ((int)listBox.Tag == 1) { bmp = Gumps.GetGump(i); } else { bmp = SecondGump.GetGump(i); } if (bmp != null) { if ((int)listBox.Tag == 1) { pictureBox1.BackgroundImage = bmp; } else { pictureBox2.BackgroundImage = bmp; } } else { if ((int)listBox.Tag == 1) { pictureBox1.BackgroundImage = null; } else { pictureBox2.BackgroundImage = null; } } } else { if ((int)listBox.Tag == 1) { pictureBox1.BackgroundImage = null; } else { pictureBox2.BackgroundImage = null; } } listBox.Invalidate(); }
protected void BuildCache() { _lblWait.Text = @"Please Wait, Generating Art Cache..."; Show(); Cache = null; _lstGump.Items.Clear(); _lblWait.Visible = true; Application.DoEvents(); int index = 0; int maxValue = ushort.MaxValue; try { do { _lblWait.Text = $@"Please Wait, Generating Art Cache... {(int) ( 100 * index / (double) maxValue )}%"; Application.DoEvents(); Bitmap gump; try { gump = Gumps.GetGump(index); } catch (Exception) { ++index; return; } if (gump != null) { if (Cache != null) { Array.Resize(ref Cache, Cache.Length + 1); } else { Cache = new GumpCacheEntry[1]; } Cache[Cache.Length - 1] = new GumpCacheEntry { ID = index, Size = gump.Size }; gump.Dispose(); } ++index; }while (index <= maxValue); using (FileStream fileStream = new FileStream(Application.StartupPath + "/GumpArt.cache", FileMode.Create)) { new BinaryFormatter().Serialize(fileStream, Cache ?? throw new InvalidOperationException()); } } catch (Exception ex) { MessageBox.Show(@"Error creating cache file:" + ex.Message); } finally { _lblWait.Visible = false; Application.DoEvents(); } }