"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Pinta.Core/Extensions/CairoExtensions.cs" between
pinta-1.7.tar.gz and pinta-1.7.1.tar.gz

About: Pinta is a powerful image drawing and editing program (modeled after Paint.NET).

CairoExtensions.cs  (pinta-1.7):CairoExtensions.cs  (pinta-1.7.1)
skipping to change at line 186 skipping to change at line 186
public static Rectangle DrawPolygonal (this Context g, PointD[] p oints, Color color) public static Rectangle DrawPolygonal (this Context g, PointD[] p oints, Color color)
{ {
g.Save (); g.Save ();
g.MoveTo (points[0]); g.MoveTo (points[0]);
foreach (var point in points) { foreach (var point in points) {
g.LineTo (point.X, point.Y); g.LineTo (point.X, point.Y);
} }
g.SetSourceColor (color); g.SetSourceColor (color);
g.LineCap = LineCap.Square;
Rectangle dirty = g.FixedStrokeExtents (); Rectangle dirty = g.FixedStrokeExtents ();
g.Stroke (); g.Stroke ();
g.Restore (); g.Restore ();
return dirty; return dirty;
} }
public static Rectangle FillPolygonal (this Context g, PointD[] p oints, Color color) public static Rectangle FillPolygonal (this Context g, PointD[] p oints, Color color)
skipping to change at line 945 skipping to change at line 946
public static Gdk.Size ToSize (this Cairo.Point point) public static Gdk.Size ToSize (this Cairo.Point point)
{ {
return new Gdk.Size (point.X, point.Y); return new Gdk.Size (point.X, point.Y);
} }
public static ImageSurface Clone (this ImageSurface surf) public static ImageSurface Clone (this ImageSurface surf)
{ {
if (PintaCore.Workspace.HasOpenDocuments) if (PintaCore.Workspace.HasOpenDocuments)
PintaCore.Workspace.ActiveDocument.SignalSurfaceC loned (); PintaCore.Workspace.ActiveDocument.SignalSurfaceC loned ();
ImageSurface newsurf = new ImageSurface (surf.Format, sur f.Width, surf.Height); ImageSurface newsurf = CairoExtensions.CreateImageSurface (surf.Format, surf.Width, surf.Height);
using (Context g = new Context (newsurf)) { using (Context g = new Context (newsurf)) {
g.SetSource (surf); g.SetSource (surf);
g.Paint (); g.Paint ();
} }
return newsurf; return newsurf;
} }
public static unsafe bool ContainsTranslucent (this ImageSurface surf) public static unsafe bool ContainsTranslucent (this ImageSurface surf)
{ {
bool ret = false; bool ret = false;
ColorBgra* ptr = (ColorBgra*)surf.DataPtr; ColorBgra* ptr = (ColorBgra*)surf.DataPtr;
int width = surf.Width; int width = surf.Width;
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
for (int y = 0; y < surf.Height; y++) { for (int y = 0; y < surf.Height; y++) {
int a = (int)surf.GetColorBgraUnchecked ( ptr, width, x, y).A; int a = (int)surf.GetColorBgraUnchecked ( ptr, width, x, y).A;
if (a > 0 && a < 255) { if (a > 0 && a < 255) {
Console.WriteLine (surf.GetColorB graUnchecked (ptr, width, x, y).ToString ()); Console.WriteLine (surf.GetColorB graUnchecked (ptr, width, x, y).ToString ());
ret = true; ret = true;
} }
skipping to change at line 1763 skipping to change at line 1765
break; break;
case BlendMode.Screen: case BlendMode.Screen:
g.Operator = (Operator)ExtendedOperators.Screen; g.Operator = (Operator)ExtendedOperators.Screen;
break; break;
case BlendMode.Xor: case BlendMode.Xor:
g.Operator = Operator.Xor; g.Operator = Operator.Xor;
break; break;
} }
} }
/*
* CreateImageSurface
* Utility function used to create new ImageSurface
* The internal creation can fail if the image is too large / not enough
memory
* This condition is detected and an exception is thrown at the applicat
ion level
*/
public static ImageSurface CreateImageSurface(Cairo.Format format, int w
idth, int height)
{
ImageSurface surf = new Cairo.ImageSurface (format, width, height);
if (surf == null || surf.Status == Cairo.Status.NoMemory)
{
throw new OutOfMemoryException ("Unable to allocate memory for Im
age");
}
return surf;
}
public enum ExtendedOperators public enum ExtendedOperators
{ {
Clear = 0, Clear = 0,
Source = 1, Source = 1,
SourceOver = 2, SourceOver = 2,
SourceIn = 3, SourceIn = 3,
SourceOut = 4, SourceOut = 4,
SourceAtop = 5, SourceAtop = 5,
 End of changes. 4 change blocks. 
1 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)