Beispiel #1
0
 public Tilesheet(EngineResourceFile resFile, string entryName)
 {
     ResourceIdentifier = new EngineResourceFileIdentifier(resFile, EngineResourceFileTypes.Bitmap, entryName);
     InitVals(entryName, null, null, ResourceIdentifier);
     ValueBag = new Dictionary<string, string>();
 }
Beispiel #2
0
 private void OnSerializing(StreamingContext context)
 {
     // if Bitmap is not a physical file and there is no ResourceFile, create resource file so it can be serialized
     if (string.IsNullOrWhiteSpace(_imgFile) && ResourceIdentifier == null)
     {
         var resFile = new EngineResourceFile(string.Format("tilesheet_{0}.zip", this.Name), null, false);
         var converter = new ImageConverter();
         resFile.Add(EngineResourceFileTypes.Bitmap, this.Name, (Stream)converter.ConvertTo(_bmp, typeof(Stream)));
         ResourceIdentifier = new EngineResourceFileIdentifier(resFile, EngineResourceFileTypes.Bitmap, this.Name);
     }
 }
Beispiel #3
0
        protected void InitVals(string name, Bitmap bmp, string bmpFilePath, EngineResourceFileIdentifier resourceId)
        {
            _name = name;

            if (bmp != null)
                _bmp = bmp;
            else
            {
                if (resourceId != null)
                    _bmp = new Bitmap(resourceId.Data);
                else
                {
                    _imgFile = bmpFilePath;
                    Bitmap tempBmp = new Bitmap(bmpFilePath);
                    _bmp = new Bitmap(tempBmp, tempBmp.Width, tempBmp.Height);
                    tempBmp.Dispose();
                }
            }

            CreateGDICompatibleBmp();

            if (Tilesheet._tilesheets.ContainsKey(_name))
                Tilesheet._tilesheets[_name].Dispose();

            Tilesheet._tilesheets.Add(_name, this);
            Tilesheet.RecalcMaxOverlapRatio();
        }
Beispiel #4
0
 public Tilesheet(EngineResourceFileIdentifier resourceId, string tilesheetName)
 {
     ResourceIdentifier = resourceId;
     InitVals(tilesheetName, null, null, ResourceIdentifier);
     ValueBag = new Dictionary<string, string>();
 }
Beispiel #5
0
 private void OnSerializing(StreamingContext context)
 {
     // if IsTempFile but no ResourceFile, create resource file so it can be serialized
     if (IsTempFile && ResourceIdentifier == null)
     {
         var resFile = new EngineResourceFile(string.Format("mediafile_{0}.zip", FileName), null, false);
         resFile.Add(ResourceFileType, Alias, InputStream);
         ResourceIdentifier = new EngineResourceFileIdentifier(resFile, ResourceFileType, Alias);
     }
 }
Beispiel #6
0
 public MediaFile(string alias, EngineResourceFileIdentifier resId, MediaFileType fileType)
     : this(alias, SaveStreamToTmpDir(resId.Data), fileType)
 {
     IsTempFile = true;
     InputStream = resId.Data;
 }