Add more queue and update functions

Add CopyTexture function
Document CDraw
This commit is contained in:
Flamefire committed 2014-09-22 15:08:45 +02:00
1 parent be67b039d6
commit c9c907e3f0
12 files changed
+652 -361

No files matched your search

+11 -11
View File
@@ -120,20 +120,20 @@ namespace VocaluxeLib
return result;
}
public static void SetRect(SRectF bounds, out SRectF rect, float rectAspect, EAspect aspect)
public static void SetRect(SRectF bounds, out SRectF rect, float aspectRatio, EAspect aspect)
{
var bounds2 = new RectangleF(bounds.X, bounds.Y, bounds.W, bounds.H);
RectangleF rect2;
SetRect(bounds2, out rect2, rectAspect, aspect);
SetRect(bounds2, out rect2, aspectRatio, aspect);
rect = new SRectF(rect2.X, rect2.Y, rect2.Width, rect2.Height, bounds.Z);
}
public static void SetRect(RectangleF bounds, out RectangleF rect, float rectAspect, EAspect aspect)
public static void SetRect(RectangleF bounds, out RectangleF rect, float aspectRatio, EAspect aspect)
{
float boundsW = bounds.Width;
float boundsH = bounds.Height;
float boundsAspect = boundsW / boundsH;
float boundsAspectRatio = boundsW / boundsH;
float scaledWidth;
float scaledHeight;
@@ -141,27 +141,27 @@ namespace VocaluxeLib
switch (aspect)
{
case EAspect.Crop:
if (boundsAspect >= rectAspect)
if (boundsAspectRatio >= aspectRatio)
{
scaledWidth = boundsW;
scaledHeight = boundsW / rectAspect;
scaledHeight = boundsW / aspectRatio;
}
else
{
scaledHeight = boundsH;
scaledWidth = boundsH * rectAspect;
scaledWidth = boundsH * aspectRatio;
}
break;
case EAspect.LetterBox:
if (boundsAspect <= rectAspect)
if (boundsAspectRatio <= aspectRatio)
{
scaledWidth = boundsW;
scaledHeight = boundsW / rectAspect;
scaledHeight = boundsW / aspectRatio;
}
else
{
scaledHeight = boundsH;
scaledWidth = boundsH * rectAspect;
scaledWidth = boundsH * aspectRatio;
}
break;
default:
@@ -179,7 +179,7 @@ namespace VocaluxeLib
/// <summary>
/// Returns a list with all files in the given path that match a given pattern
/// </summary>
/// <param name="path">Path to search for</param>
/// <param name="path">Path to search</param>
/// <param name="searchPattern">Pattern to match (e.g. "*.jpg")</param>
/// <param name="recursive">Search directories recursively</param>
/// <param name="fullpath">False for just file names, True for full path</param>
+20 -10
View File
@@ -15,6 +15,7 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Drawing;
namespace VocaluxeLib.Draw
@@ -22,10 +23,9 @@ namespace VocaluxeLib.Draw
/// <summary>
/// Reference to a texture in the drawing driver
/// </summary>
public class CTextureRef
public class CTextureRef : IDisposable
{
public int ID;
public int ID { get; private set; }
/// <summary>
/// Size of original image (e.g. of bmp)
/// </summary>
@@ -56,22 +56,32 @@ namespace VocaluxeLib.Draw
Rect = new SRectF(0f, 0f, origSize.Width, origSize.Height, 0f);
}
public void CopyFieldsFrom(CTextureRef other)
~CTextureRef()
{
ID = other.ID;
OrigSize = other.OrigSize;
Rect = other.Rect;
Color = other.Color;
Dispose();
}
~CTextureRef()
public void Dispose()
{
if (ID >= 0)
{
//Free textures that are no longer reference
//Free textures that are no longer referenced
CTextureRef tmp = this;
CBase.Drawing.RemoveTexture(ref tmp);
}
SetRemoved();
}
/// <summary>
/// Call this from the graphics driver to denote that this reference is remove and no longer valid <br />
/// This avoids the finalizer
/// </summary>
public void SetRemoved()
{
if (ID < 0)
throw new ObjectDisposedException(GetType().Name);
ID = -1;
GC.SuppressFinalize(this);
}
}
}