本文整理汇总了C#中Gdk.Rectangle.GetBottom方法的典型用法代码示例。如果您正苦于以下问题:C# Gdk.Rectangle.GetBottom方法的具体用法?C# Gdk.Rectangle.GetBottom怎么用?C# Gdk.Rectangle.GetBottom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdk.Rectangle
的用法示例。
在下文中一共展示了Gdk.Rectangle.GetBottom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPixelsFromPoint
private ColorBgra[] GetPixelsFromPoint(PointD point)
{
var doc = PintaCore.Workspace.ActiveDocument;
var x = (int)point.X;
var y = (int)point.Y;
var size = SampleSize;
var half = size / 2;
// Short circuit for single pixel
if (size == 1)
return new ColorBgra[] { GetPixel (x, y) };
// Find the pixels we need (clamp to the size of the image)
var rect = new Gdk.Rectangle (x - half, y - half, size, size);
rect.Intersect (new Gdk.Rectangle (Gdk.Point.Zero, doc.ImageSize));
var pixels = new List<ColorBgra> ();
for (int i = rect.Left; i <= rect.GetRight (); i++)
for (int j = rect.Top; j <= rect.GetBottom (); j++)
pixels.Add (GetPixel (i, j));
return pixels.ToArray ();
}
示例2: Create
public static unsafe SurfaceDiff Create (ImageSurface original, ImageSurface updated_surf, bool force = false)
{
if (original.Width != updated_surf.Width || original.Height != updated_surf.Height) {
// If the surface changed size, only throw an error if the user forced the use of a diff.
if (force) {
throw new InvalidOperationException ("SurfaceDiff requires surfaces to be same size.");
} else {
return null;
}
}
// Cache some pinvokes
var orig_width = original.Width;
var orig_height = original.Height;
#if DEBUG_DIFF
Console.WriteLine ("Original surface size: {0}x{1}", orig_width, orig_height);
System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
timer.Start();
#endif
// STEP 1 - Find the bounds of the changed pixels.
var orig_ptr = (int*)original.DataPtr;
var updated_ptr = (int*)updated_surf.DataPtr;
DiffBounds diff_bounds = new DiffBounds (orig_width, orig_height);
object diff_bounds_lock = new Object();
// Split up the work among several threads, each of which processes one row at a time
// and updates the bounds of the changed pixels it has seen so far. At the end, the
// results from each thread are merged together to find the overall bounds of the changed
// pixels.
Parallel.For<DiffBounds>(0, orig_height, () => new DiffBounds (orig_width, orig_height),
(row, loop, my_bounds) => {
var offset = row * orig_width;
var orig = orig_ptr + offset;
var updated = updated_ptr + offset;
bool change_in_row = false;
for (int i = 0; i < orig_width; ++i) {
if (*(orig++) != *(updated++)) {
change_in_row = true;
my_bounds.left = System.Math.Min(my_bounds.left, i);
my_bounds.right = System.Math.Max(my_bounds.right, i);
}
}
if (change_in_row) {
my_bounds.top = System.Math.Min(my_bounds.top, row);
my_bounds.bottom = System.Math.Max(my_bounds.bottom, row);
}
return my_bounds;
}, (my_bounds) => {
lock (diff_bounds_lock) {
diff_bounds.Merge (my_bounds);
}
return;
});
var bounds = new Gdk.Rectangle (diff_bounds.left, diff_bounds.top,
diff_bounds.right - diff_bounds.left + 1,
diff_bounds.bottom - diff_bounds.top + 1);
#if DEBUG_DIFF
Console.WriteLine ("Truncated surface size: {0}x{1}", bounds.Width, bounds.Height);
#endif
// STEP 2 - Create a bitarray of whether each pixel in the bounds has changed, and count
// how many changed pixels we need to store.
var bitmask = new BitArray (bounds.Width * bounds.Height);
int index = 0;
int num_changed = 0;
int bottom = bounds.GetBottom ();
int right = bounds.GetRight ();
int bounds_x = bounds.X;
int bounds_y = bounds.Y;
for (int y = bounds_y; y <= bottom; ++y) {
var offset = y * orig_width;
var updated = updated_ptr + offset + bounds_x;
var orig = orig_ptr + offset + bounds_x;
for (int x = bounds_x; x <= right; ++x) {
bool changed = *(orig++) != *(updated++);
bitmask[index++] = changed;
if (changed) {
num_changed++;
}
}
}
var savings = 100 - (float)num_changed / (float)(orig_width * orig_height) * 100;
#if DEBUG_DIFF
Console.WriteLine ("Compressed bitmask: {0}/{1} = {2}%", num_changed, orig_height * orig_width, 100 - savings);
#endif
//.........这里部分代码省略.........