本文整理汇总了C#中Gdk.Pixbuf.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Pixbuf.Clone方法的具体用法?C# Pixbuf.Clone怎么用?C# Pixbuf.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdk.Pixbuf
的用法示例。
在下文中一共展示了Pixbuf.Clone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
{
Pixbuf output = (Pixbuf) input.Clone ();
return output.Flip (true);
}
示例2: EnhancedSimdSupport
/* static bool enhanced_support = EnhancedSimdSupport ();
static bool EnhancedSimdSupport () { //require sse3
return SimdRuntime.IsMethodAccelerated (typeof (VectorOperations), "HorizontalAdd", new Type[] {typeof (Vector4f), typeof (Vector4f)})
&& SimdRuntime.IsMethodAccelerated (typeof (Vector4f), "op_Multiply");
}*/
protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
{
uint timer = Log.DebugTimerStart ();
if (input.BitsPerSample != 8) {
Log.Warning ("unsupported pixbuf format");
return (Pixbuf)input.Clone ();
}
Pixbuf output = new Pixbuf (input.Colorspace, input.HasAlpha, input.BitsPerSample, input.Width, input.Height);
Vector4f multiply = new Vector4f ((float)(r.Value/100.0), (float)(g.Value/100.0), (float)(b.Value/100.0), 0);
Normalize (ref multiply);
bool has_alpha = input.HasAlpha;
int chan = input.NChannels;
int rowstride_in = input.Rowstride;
int rowstride_out = output.Rowstride;
Vector4f v_in;
Vector4f v_out = new Vector4f (0);
float[] fcurve = new float [256];
c.GetVector (fcurve.Length, fcurve);
byte[] curve = new byte [fcurve.Length];
for (int i = 0; i < fcurve.Length; i++)
curve[i] = (byte)fcurve[i];
unsafe {
byte *pix_in = (byte *)input.Pixels;
byte *pix_out = (byte *)output.Pixels;
for (int i=0; i < input.Height; i++)
for (int j=0; j<input.Width; j++) {
v_in = new Vector4f (pix_in[i*rowstride_in + j*chan],
pix_in[i*rowstride_in + j*chan + 1],
pix_in[i*rowstride_in + j*chan + 2],
0);
Desaturate (ref v_in, ref multiply, ref v_out);
pix_out[i*rowstride_out + j*chan] = curve [unchecked ((byte)v_out.X)];
pix_out[i*rowstride_out + j*chan + 1] = curve [unchecked ((byte)v_out.Y)];
pix_out[i*rowstride_out + j*chan + 2] = curve [unchecked ((byte)v_out.Z)];
if (has_alpha)
pix_out[i*rowstride_out + j*chan + 3] = pix_in[i*rowstride_in + j*chan + 3];
}
}
Log.DebugTimerPrint (timer, "Processing took {0}");
return output;
}
示例3: SaveThumbnail
public static void SaveThumbnail(Pixbuf pixbuf, Uri image_uri, DateTime original_mtime)
{
cache[image_uri]=pixbuf.Clone() as Pixbuf;
}
示例4: Process
protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
{
Pixbuf output = (Pixbuf) input.Clone ();
double ratio = (double)size.Value / Math.Max (output.Width, output.Height);
return output.ScaleSimple ((int)(output.Width * ratio), (int)(output.Height * ratio), InterpType.Bilinear);
}
示例5: getDiff
static Pixbuf getDiff(Pixbuf A, Pixbuf B, out string diffstring, out double r2)
{
// r2 as in http://en.wikipedia.org/wiki/Coefficient_of_determination
diffstring = "";
r2 = 0;
if (A.Width != B.Width || A.Height != B.Height) {
B = B.ScaleSimple (A.Width, A.Height, Gdk.InterpType.Nearest);
diffstring = string.Format ("Different sizes.\n");
}
if (A.HasAlpha != B.HasAlpha) {
if (A.HasAlpha && !B.HasAlpha)
diffstring += string.Format ("Reference image doesn't have an alpha channel. But the new image does.\n");
else
diffstring += string.Format ("Reference image has an alpha channel. But the new image doesn't.\n");
} else {
if (A.Rowstride != B.Rowstride) {
diffstring += string.Format ("Different rowstride.\n");
}
}
if (A.NChannels - (A.HasAlpha ? 1 : 0) != B.NChannels - (B.HasAlpha ? 1 : 0)) {
diffstring += string.Format ("Different number of channels.");
return null;
}
if (A.BitsPerSample != B.BitsPerSample) {
diffstring += string.Format ("Different bits per sample\n");
return null;
}
if (A.BitsPerSample != 8) {
diffstring += string.Format ("Only support diffs of images with 8 bits per sample, got {1}.", A.BitsPerSample);
return null;
}
Gdk.Pixbuf C = (Gdk.Pixbuf)A.Clone ();
double v = 0;
double amean = 0;
double cmean = 0;
double asum = 0;
unsafe {
byte* a = (byte*)A.Pixels;
byte* b = (byte*)B.Pixels;
byte* c = (byte*)C.Pixels;
int bnc = B.NChannels;
int anc = A.NChannels;
int nc = bnc < anc ? bnc : anc;
int w = A.Width;
for (int y=0; y<A.Height; ++y) {
int oa = y * A.Rowstride;
int ob = y * B.Rowstride;
for (int n=0; n<w; ++n)
{
for (int m=0; m<nc; ++m) {
int o = oa + n*anc + m;
int d = ((int)a [o]) - (int)b [ob + n*bnc + m];
if (d < 0) d = -d;
amean += a [o];
c [o] = (byte)d;
cmean += d;
v += d * d;
}
if (C.HasAlpha)
c [oa + n*anc + anc-1] = 255;
}
}
amean /= (double)A.Height * A.Width * A.NChannels;
cmean /= (double)C.Height * C.Width * C.NChannels;
double scale = Math.Max(1, 32.0/cmean);
// Compute R2 denominator sum from 'a', and normalize 'c'
for (int y=0; y<A.Height; ++y) {
int o = y * A.Rowstride; // C is a copy of A and thus have the same Rowstride.
for (int x=0; x<anc*w; ++x) {
double d = a[o+x] - amean;
asum += d*d;
c[o+x] = (byte)Math.Min (255.0, c[o+x]*scale);
}
}
}
r2 = 1 - v/asum;
diffstring += r2.ToString("G");
return C;
}