public static bool ExportSprite(AssetItem item, string exportPath) { ImageFormat format = null; var type = (string)Properties.Settings.Default["convertType"]; switch (type) { case "BMP": format = ImageFormat.Bmp; break; case "PNG": format = ImageFormat.Png; break; case "JPEG": format = ImageFormat.Jpeg; break; } var exportFullName = exportPath + item.Text + "." + type.ToLower(); if (ExportFileExists(exportFullName)) { return(false); } var bitmap = SpriteHelper.GetImageFromSprite((Sprite)item.Asset); if (bitmap != null) { bitmap.Save(exportFullName, format); bitmap.Dispose(); return(true); } return(false); }
public static bool ExportSprite(AssetItem item, string exportPath) { ImageFormat format = null; var type = Properties.Settings.Default.convertType; bool tga = false; switch (type) { case "BMP": format = ImageFormat.Bmp; break; case "PNG": format = ImageFormat.Png; break; case "JPEG": format = ImageFormat.Jpeg; break; case "TGA": tga = true; break; } var exportFullName = exportPath + item.Text + "." + type.ToLower(); if (ExportFileExists(exportFullName)) { return(false); } var bitmap = SpriteHelper.GetImageFromSprite((Sprite)item.Asset); if (bitmap != null) { if (tga) { TGASharpLib.TGA file = new TGASharpLib.TGA(bitmap); file.Save(exportFullName); } else { bitmap.Save(exportFullName, format); } bitmap.Dispose(); return(true); } return(false); }
public static bool ExportSprite(AssetItem item, string exportPath, string format) { ImageFormat dstFormat = null; if (format == "recommanded") { format = "png"; } var oriPath = item.Asset.assetsFile.originalPath; var exportFullName = exportPath + Path.GetFileNameWithoutExtension(oriPath) + "." + format; var m_TextAsset = (TextAsset)(item.Asset); switch (format) { case "bmp": dstFormat = ImageFormat.Bmp; break; case "png": dstFormat = ImageFormat.Png; break; case "jpg": dstFormat = ImageFormat.Jpeg; break; } var bitmap = SpriteHelper.GetImageFromSprite((Sprite)item.Asset); if (bitmap != null) { bitmap.Save(exportFullName, dstFormat); bitmap.Dispose(); return(true); } return(false); }