public bool load_imageset(GameControls.XLBE.Resource_Manager.Imageset_Res imageRes) { try { Imageset imageSet = new Imageset(imageRes.name_); XDocument configXml = XDocument.Load(imageRes.path_); System.Drawing.Bitmap bitmap = null; var imageset = configXml.Descendants("Imageset"); foreach (XElement element in imageset) { string filePath = AppDomain.CurrentDomain.BaseDirectory + (string)element.Attribute("Image"); bitmap = new System.Drawing.Bitmap(filePath); break; } List <Image> imageList = new List <Image>(); var images = configXml.Descendants("Image"); foreach (XElement imageElement in images) { string imageName = (string)imageElement.Attribute("Name"); Rect area = new Rect(); area.origin_.x_ = (int)imageElement.Attribute("XPos"); area.origin_.y_ = (int)imageElement.Attribute("YPos"); area.size_.width_ = (int)imageElement.Attribute("Width"); area.size_.height_ = (int)imageElement.Attribute("Height"); System.Drawing.Bitmap subBmp = new System.Drawing.Bitmap((int)area.width(), (int)area.height()); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(subBmp); System.Drawing.Rectangle destRect = new System.Drawing.Rectangle(0, 0, subBmp.Width, subBmp.Height); g.DrawImage(bitmap, destRect, (int)area.origin_.x_, (int)area.origin_.y_, subBmp.Width, subBmp.Height, System.Drawing.GraphicsUnit.Pixel); g.Dispose(); Render_Texture texture = Root.instance().render_system().add_texture(subBmp); Image image = new Image(imageName, area, texture); imageSet.insert_image(image); } _imagesetDic.Add(imageRes.name_, imageSet); } catch { return(false); } return(true); }
//public abstract void remove_texture(Render_Texture tex); //public abstract void remove_texture(string name); //public abstract void remove_all_texture(); public void render_image(Render_Texture texture, Rect srcRect, Rect destRect, Point hot, double rotation) { d3d_texture d3dTexture = (d3d_texture)texture; if (hot == null) { hot = new Point(srcRect.width() / 2, srcRect.height() / 2); } //if( rotation == 0 ) // rotateOffset = new System.Drawing.Point(0,0); render_image(d3dTexture._Sprite, d3dTexture._Texture, hot, rotation, (int)destRect.origin_.x_, (int)destRect.origin_.y_, (int)destRect.width(), (int)destRect.height(), (int)srcRect.origin_.x_, (int)srcRect.origin_.y_, (int)srcRect.width(), (int)srcRect.height(), 255); }
public Image(string name, Rect area, Render_Texture texture) { name_ = name; area_ = area; texture_ = texture; }