public NBTTagCompound ImageConvert(Bitmap bmp, bool IsSchematic, ref BackgroundWorker bw) { var schema = new SilverNBTLibrary.Structure.Schematic(bmp.Width, 1, bmp.Height); var mapbyte = new byte[16384]; var compound = new NBTTagCompound(); int i = 0; using (BitmapAccessor accessor = new BitmapAccessor(bmp)) { for (int y = 0; y < bmp.Height; y++) { for (int x = 0; x < bmp.Width; x++) { Color bitmapRGB = accessor.GetPixel(x, y); var block = IsSchematic ? RGBToBlockColor(bitmapRGB) : RGBToMapColor(bitmapRGB); if (IsSchematic) { schema.SetBlock(x, 0, y, block.ID, block.Meta); } else { mapbyte[i] = (byte)block.ID; i++; } } bw.ReportProgress(y); } } if (IsSchematic) { compound = schema.SaveToNBT(); } else { var map = new NBTTagByteArray("colors", mapbyte); compound = NBTFile.LoadFromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"\data\MapTemplate.dat"); var data = (NBTTagCompound)compound.GetTag("data"); data.Add(map); } bmp.Dispose(); return(compound); }