Deal with poorly sized images. Make an X sprite showing an error instead of crashing out.
This commit is contained in:
parent
244ab8373f
commit
ccdc4e0dd6
14
SpriteLibrary/Properties/Resources.Designer.cs
generated
14
SpriteLibrary/Properties/Resources.Designer.cs
generated
@ -61,8 +61,8 @@ namespace SpriteLibrary.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to {\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff0\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi0\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f34\fbidi \froman\fcharset0\fprq2{\*\panose 00000000000000000000}Cambria Math;}
|
/// Looks up a localized string similar to {\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff0\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi0\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f34\fbidi \froman\fcharset1\fprq2{\*\panose 02040503050406030204}Cambria Math;}
|
||||||
///{\f39\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\f40\fbidi \fmodern\fcharset0\fprq1{\*\panose 020b0609020204030204}Consolas;}{\flomajor [rest of string was truncated]";.
|
///{\f39\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\f40\fbidi \fmodern\fcharset0\fprq1{\*\panose 00000000000000000000}Consolas;}{\flomajor [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ChangeLog {
|
internal static string ChangeLog {
|
||||||
get {
|
get {
|
||||||
@ -89,5 +89,15 @@ namespace SpriteLibrary.Properties {
|
|||||||
return ((System.Drawing.Icon)(obj));
|
return ((System.Drawing.Icon)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap X {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("X", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
SpriteLibrary/Resources/X.png
Normal file
BIN
SpriteLibrary/Resources/X.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
@ -94,6 +94,17 @@ namespace SpriteLibrary
|
|||||||
y += height;
|
y += height;
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
|
//If we managed to send it a bad size or something and we could not make a single image.
|
||||||
|
if(Frames.Count ==0)
|
||||||
|
{
|
||||||
|
Bitmap tImage = new Bitmap(width, height);
|
||||||
|
Image XImage = Properties.Resources.X;
|
||||||
|
Graphics.FromImage(tImage).DrawImage(Properties.Resources.X,0,0,tImage.Width,tImage.Height);
|
||||||
|
AnimationSingleFrame newSingle = new AnimationSingleFrame(tImage, Smart_Image.FrameCount);
|
||||||
|
AnimationFrame newFrame = new AnimationFrame(Smart_Image.FrameCount, TimeSpan.FromMilliseconds(duration));
|
||||||
|
Frames.Add(newFrame);
|
||||||
|
Smart_Image.AddFrame(newSingle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -131,6 +142,17 @@ namespace SpriteLibrary
|
|||||||
y += height;
|
y += height;
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
|
//If we managed to send it a bad size or something and we could not make a single image.
|
||||||
|
if (Frames.Count == 0)
|
||||||
|
{
|
||||||
|
Bitmap tImage = new Bitmap(width, height);
|
||||||
|
Image XImage = Properties.Resources.X;
|
||||||
|
Graphics.FromImage(tImage).DrawImage(Properties.Resources.X, 0, 0, tImage.Width, tImage.Height);
|
||||||
|
AnimationSingleFrame newSingle = new AnimationSingleFrame(tImage, Smart_Image.FrameCount);
|
||||||
|
AnimationFrame newFrame = new AnimationFrame(Smart_Image.FrameCount, TimeSpan.FromMilliseconds(duration));
|
||||||
|
Frames.Add(newFrame);
|
||||||
|
Smart_Image.AddFrame(newSingle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Animation(SmartImage Smart_Image, int AnimationToCopy, bool MirrorHorizontally, bool MirrorVertically)
|
internal Animation(SmartImage Smart_Image, int AnimationToCopy, bool MirrorHorizontally, bool MirrorVertically)
|
||||||
|
@ -89,6 +89,9 @@
|
|||||||
<None Include="Resources\licence.rtf" />
|
<None Include="Resources\licence.rtf" />
|
||||||
<None Include="Resources\SLIcon.ico" />
|
<None Include="Resources\SLIcon.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\X.png" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
Loading…
Reference in New Issue
Block a user