本文整理汇总了C#中ISurface.GetPointAddress方法的典型用法代码示例。如果您正苦于以下问题:C# ISurface.GetPointAddress方法的具体用法?C# ISurface.GetPointAddress怎么用?C# ISurface.GetPointAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISurface
的用法示例。
在下文中一共展示了ISurface.GetPointAddress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderLine
protected unsafe override void RenderLine (ISurface src, ISurface dest, Rectangle rect)
{
for (int y = rect.Top; y <= rect.Bottom; ++y) {
int yEnd = y + 1;
for (int x = rect.Left; x <= rect.Right; ++x) {
var cellRect = GetCellBox (x, y, cell_size);
cellRect.Intersect (dest.Bounds);
var color = ComputeCellColor (x, y, src, cell_size, src.Bounds);
int xEnd = Math.Min (rect.Right, cellRect.Right);
yEnd = Math.Min (rect.Bottom, cellRect.Bottom);
for (int y2 = y; y2 <= yEnd; ++y2) {
ColorBgra* ptr = dest.GetPointAddress (x, y2);
for (int x2 = x; x2 <= xEnd; ++x2) {
ptr->Bgra = color.Bgra;
++ptr;
}
}
x = xEnd;
}
y = yEnd;
}
}
示例2: RenderLine
protected unsafe override void RenderLine (ISurface src, ISurface dst, Rectangle rect)
{
double[,] weights = Weights;
var srcWidth = src.Width;
var srcHeight = src.Height;
// loop through each line of target rectangle
for (int y = rect.Top; y <= rect.Bottom; ++y) {
int fyStart = 0;
int fyEnd = 3;
if (y == 0)
fyStart = 1;
if (y == srcHeight - 1)
fyEnd = 2;
// loop through each point in the line
ColorBgra* dstPtr = dst.GetPointAddress (rect.Left, y);
for (int x = rect.Left; x <= rect.Right; ++x) {
int fxStart = 0;
int fxEnd = 3;
if (x == 0)
fxStart = 1;
if (x == srcWidth - 1)
fxEnd = 2;
// loop through each weight
double sum = 0.0;
for (int fy = fyStart; fy < fyEnd; ++fy) {
for (int fx = fxStart; fx < fxEnd; ++fx) {
double weight = weights[fy, fx];
ColorBgra c = src.GetPoint (x - 1 + fx, y - 1 + fy);
double intensity = (double)c.GetIntensityByte ();
sum += weight * intensity;
}
}
int iSum = (int)sum;
iSum += 128;
if (iSum > 255)
iSum = 255;
if (iSum < 0)
iSum = 0;
*dstPtr = ColorBgra.FromBgra ((byte)iSum, (byte)iSum, (byte)iSum, 255);
++dstPtr;
}
}
}
示例3: RenderLine
protected unsafe override void RenderLine (ISurface src, ISurface dst, Rectangle rect)
{
const double jr = 0.3125;
const double ji = 0.03;
int w = dst.Width;
int h = dst.Height;
double invH = 1.0 / h;
double invZoom = 1.0 / zoom;
double invQuality = 1.0 / quality;
double aspect = (double)h / (double)w;
int count = quality * quality + 1;
double invCount = 1.0 / (double)count;
double angleTheta = (angle * Math.PI * 2) / 360.0;
for (int y = rect.Top; y <= rect.Bottom; y++) {
ColorBgra* dstPtr = dst.GetPointAddress (rect.Left, y);
for (int x = rect.Left; x <= rect.Right; x++) {
int r = 0;
int g = 0;
int b = 0;
int a = 0;
for (double i = 0; i < count; i++) {
double u = (2.0 * x - w + (i * invCount)) * invH;
double v = (2.0 * y - h + ((i * invQuality) % 1)) * invH;
double radius = Math.Sqrt ((u * u) + (v * v));
double radiusP = radius;
double theta = Math.Atan2 (v, u);
double thetaP = theta + angleTheta;
double uP = radiusP * Math.Cos (thetaP);
double vP = radiusP * Math.Sin (thetaP);
double jX = (uP - vP * aspect) * invZoom;
double jY = (vP + uP * aspect) * invZoom;
double j = Julia (jX, jY, jr, ji);
double c = factor * j;
b += Utility.ClampToByte (c - 768);
g += Utility.ClampToByte (c - 512);
r += Utility.ClampToByte (c - 256);
a += Utility.ClampToByte (c - 0);
}
*dstPtr = ColorBgra.FromBgra (Utility.ClampToByte (b / count), Utility.ClampToByte (g / count), Utility.ClampToByte (r / count), Utility.ClampToByte (a / count));
++dstPtr;
}
}
}
示例4: RenderLine
protected unsafe override void RenderLine (ISurface src, ISurface dest, Rectangle roi)
{
blur_effect.Render (src, dest, roi);
contrast_effect.Render (dest, dest, roi);
for (var y = roi.Top; y <= roi.Bottom; ++y) {
var dstPtr = dest.GetPointAddress (roi.Left, y);
var srcPtr = src.GetPointAddress (roi.Left, y);
screen_op.Apply (srcPtr, dstPtr, dstPtr, roi.Width);
}
}
示例5: RenderLine
protected unsafe override void RenderLine (ISurface src, ISurface dst, Rectangle rect)
{
PointD start = new PointD (0, 0);
double theta = ((double)(angle + 180) * 2 * Math.PI) / 360.0;
double alpha = (double)distance;
PointD end = new PointD ((float)alpha * Math.Cos (theta), (float)(-alpha * Math.Sin (theta)));
if (centered) {
start.X = -end.X / 2.0f;
start.Y = -end.Y / 2.0f;
end.X /= 2.0f;
end.Y /= 2.0f;
}
PointD[] points = new PointD[((1 + distance) * 3) / 2];
if (points.Length == 1) {
points[0] = new PointD (0, 0);
} else {
for (int i = 0; i < points.Length; ++i) {
float frac = (float)i / (float)(points.Length - 1);
points[i] = Utility.Lerp (start, end, frac);
}
}
ColorBgra* samples = stackalloc ColorBgra[points.Length];
int src_width = src.Width;
int src_height = src.Height;
for (int y = rect.Top; y <= rect.Bottom; ++y) {
ColorBgra* dstPtr = dst.GetPointAddress (rect.Left, y);
for (int x = rect.Left; x <= rect.Right; ++x) {
int sampleCount = 0;
for (int j = 0; j < points.Length; ++j) {
PointD pt = new PointD (points[j].X + (float)x, points[j].Y + (float)y);
if (pt.X >= 0 && pt.Y >= 0 && pt.X <= (src_width - 1) && pt.Y <= (src_height - 1)) {
samples[sampleCount] = Utility.GetBilinearSampleClamped (src, (float)pt.X, (float)pt.Y);
++sampleCount;
}
}
*dstPtr = ColorBgra.Blend (samples, sampleCount);
++dstPtr;
}
}
}
示例6: AddSurfaceRectangleToHistogram
protected override unsafe void AddSurfaceRectangleToHistogram (ISurface surface, Rectangle rect)
{
long[] histogramB = histogram[0];
long[] histogramG = histogram[1];
long[] histogramR = histogram[2];
int rect_right = rect.Right;
for (int y = rect.Y; y <= rect.Bottom; ++y) {
ColorBgra* ptr = surface.GetPointAddress (rect.X, y);
for (int x = rect.X; x <= rect_right; ++x) {
++histogramB[ptr->B];
++histogramG[ptr->G];
++histogramR[ptr->R];
++ptr;
}
}
}
示例7: RenderLine
protected unsafe override void RenderLine (ISurface src, ISurface dest, Rectangle roi)
{
bac_adjustment.Render (src, dest, roi);
blur_effect.Render (src, dest, roi);
invert_effect.Render (dest, dest, roi);
desaturate_op.Apply (dest, dest, roi);
for (int y = roi.Top; y <= roi.Bottom; ++y) {
var srcPtr = src.GetPointAddress (roi.X, y);
var dstPtr = dest.GetPointAddress (roi.X, y);
for (int x = roi.Left; x <= roi.Right; ++x) {
var srcGrey = desaturate_op.Apply (*srcPtr);
var sketched = color_dodge_op.Apply (srcGrey, *dstPtr);
*dstPtr = sketched;
++srcPtr;
++dstPtr;
}
}
}
示例8: RenderLine
protected unsafe override void RenderLine (ISurface src, ISurface dst, Rectangle rect)
{
var bulge = (float)amount;
var hw = dst.Width / 2f;
var hh = dst.Height / 2f;
var maxrad = Math.Min (hw, hh);
var amt = bulge / 100f;
hh = hh + (float)offset.Y * hh;
hw = hw + (float)offset.X * hw;
for (var y = rect.Top; y <= rect.Bottom; y++) {
var dstPtr = dst.GetPointAddress (rect.Left, y);
var srcPtr = src.GetPointAddress (rect.Left, y);
var v = y - hh;
for (var x = rect.Left; x <= rect.Right; x++) {
var u = x - hw;
var r = (float)Math.Sqrt (u * u + v * v);
var rscale1 = (1f - (r / maxrad));
if (rscale1 > 0) {
var rscale2 = 1 - amt * rscale1 * rscale1;
var xp = u * rscale2;
var yp = v * rscale2;
*dstPtr = Utility.GetBilinearSampleClamped (src, xp + hw, yp + hh);
} else {
*dstPtr = *srcPtr;
}
++dstPtr;
++srcPtr;
}
}
}
示例9: RenderLine
protected unsafe override void RenderLine (ISurface src, ISurface dst, Rectangle rect)
{
var pointOffsets = RecalcPointOffsets (fragments, rotation, distance);
int poLength = pointOffsets.Length;
Point* pointOffsetsPtr = stackalloc Point[poLength];
for (int i = 0; i < poLength; ++i)
pointOffsetsPtr[i] = pointOffsets[i];
ColorBgra* samples = stackalloc ColorBgra[poLength];
int src_width = src.Width;
int src_height = src.Height;
for (int y = rect.Top; y <= rect.Bottom; y++) {
ColorBgra* dstPtr = dst.GetPointAddress (rect.Left, y);
for (int x = rect.Left; x <= rect.Right; x++) {
int sampleCount = 0;
for (int i = 0; i < poLength; ++i) {
int u = x - pointOffsetsPtr[i].X;
int v = y - pointOffsetsPtr[i].Y;
if (u >= 0 && u < src_width && v >= 0 && v < src_height) {
samples[sampleCount] = src.GetPoint (u, v);
++sampleCount;
}
}
*dstPtr = ColorBgra.Blend (samples, sampleCount);
++dstPtr;
}
}
}
示例10: Render
public unsafe void Render (ISurface surface, params Rectangle[] rois)
{
byte startAlpha;
byte endAlpha;
if (this.AlphaOnly) {
ComputeAlphaOnlyValuesFromColors (this.startColor, this.endColor, out startAlpha, out endAlpha);
} else {
startAlpha = this.startColor.A;
endAlpha = this.endColor.A;
}
surface.BeginUpdate ();
for (int ri = 0; ri < rois.Length; ++ri) {
var rect = rois[ri];
if (this.StartPoint.X == this.EndPoint.X && this.StartPoint.Y == this.EndPoint.Y) {
// Start and End point are the same ... fill with solid color.
for (int y = rect.Top; y <= rect.Bottom; ++y) {
var pixelPtr = surface.GetPointAddress(rect.Left, y);
for (int x = rect.Left; x <= rect.Right; ++x) {
ColorBgra result;
if (this.AlphaOnly && this.AlphaBlending) {
byte resultAlpha = (byte)Utility.FastDivideShortByByte ((ushort)(pixelPtr->A * endAlpha), 255);
result = *pixelPtr;
result.A = resultAlpha;
} else if (this.AlphaOnly && !this.AlphaBlending) {
result = *pixelPtr;
result.A = endAlpha;
} else if (!this.AlphaOnly && this.AlphaBlending) {
result = this.normalBlendOp.Apply (*pixelPtr, this.endColor);
//if (!this.alphaOnly && !this.alphaBlending)
} else {
result = this.endColor;
}
*pixelPtr = result;
++pixelPtr;
}
}
} else {
var mainrect = rect;
Parallel.ForEach(Enumerable.Range (rect.Top, rect.Bottom + 1),
(y) => ProcessGradientLine(startAlpha, endAlpha, y, mainrect, surface));
}
}
surface.EndUpdate ();
AfterRender ();
}
示例11: ProcessGradientLine
private unsafe bool ProcessGradientLine (byte startAlpha, byte endAlpha, int y, Rectangle rect, ISurface surface)
{
var pixelPtr = surface.GetPointAddress (rect.Left, y);
var right = rect.Right;
if (AlphaOnly && AlphaBlending)
{
for (var x = rect.Left; x <= right; ++x)
{
var lerpByte = ComputeByteLerp(x, y);
var lerpAlpha = lerpAlphas[lerpByte];
var resultAlpha = Utility.FastScaleByteByByte(pixelPtr->A, lerpAlpha);
pixelPtr->A = resultAlpha;
++pixelPtr;
}
}
else if (AlphaOnly && !AlphaBlending)
{
for (var x = rect.Left; x <= right; ++x)
{
var lerpByte = ComputeByteLerp(x, y);
var lerpAlpha = lerpAlphas[lerpByte];
pixelPtr->A = lerpAlpha;
++pixelPtr;
}
}
else if (!AlphaOnly && (AlphaBlending && (startAlpha != 255 || endAlpha != 255)))
{
// If we're doing all color channels, and we're doing alpha blending, and if alpha blending is necessary
for (var x = rect.Left; x <= right; ++x)
{
var lerpByte = ComputeByteLerp(x, y);
var lerpColor = lerpColors[lerpByte];
var result = normalBlendOp.Apply((*pixelPtr), lerpColor);
*pixelPtr = result;
++pixelPtr;
}
//if (!this.alphaOnly && !this.alphaBlending) // or sC.A == 255 && eC.A == 255
}
else
{
for (var x = rect.Left; x <= right; ++x)
{
var lerpByte = ComputeByteLerp(x, y);
var lerpColor = lerpColors[lerpByte];
*pixelPtr = lerpColor;
++pixelPtr;
}
}
return true;
}
示例12: RenderLine
protected unsafe override void RenderLine (ISurface src, ISurface dest, Rectangle rect)
{
int width = src.Width;
int height = src.Height;
int arrayLens = 1 + coarseness;
int localStoreSize = arrayLens * 5 * sizeof (int);
byte* localStore = stackalloc byte[localStoreSize];
byte* p = localStore;
int* intensityCount = (int*)p;
p += arrayLens * sizeof (int);
uint* avgRed = (uint*)p;
p += arrayLens * sizeof (uint);
uint* avgGreen = (uint*)p;
p += arrayLens * sizeof (uint);
uint* avgBlue = (uint*)p;
p += arrayLens * sizeof (uint);
uint* avgAlpha = (uint*)p;
p += arrayLens * sizeof (uint);
byte maxIntensity = (byte)coarseness;
int rectTop = rect.Top;
int rectBottom = rect.Bottom;
int rectLeft = rect.Left;
int rectRight = rect.Right;
for (int y = rectTop; y <= rectBottom; ++y) {
ColorBgra* dstPtr = dest.GetPointAddress (rect.Left, y);
int top = y - brush_size;
int bottom = y + brush_size + 1;
if (top < 0) {
top = 0;
}
if (bottom > height) {
bottom = height;
}
for (int x = rectLeft; x <= rectRight; ++x) {
SetToZero (localStore, (ulong)localStoreSize);
int left = x - brush_size;
int right = x + brush_size + 1;
if (left < 0) {
left = 0;
}
if (right > width) {
right = width;
}
int numInt = 0;
for (int j = top; j < bottom; ++j) {
ColorBgra* srcPtr = src.GetPointAddress (left, j);
for (int i = left; i < right; ++i) {
byte intensity = Utility.FastScaleByteByByte (srcPtr->GetIntensityByte (), maxIntensity);
++intensityCount[intensity];
++numInt;
avgRed[intensity] += srcPtr->R;
avgGreen[intensity] += srcPtr->G;
avgBlue[intensity] += srcPtr->B;
avgAlpha[intensity] += srcPtr->A;
++srcPtr;
}
}
byte chosenIntensity = 0;
int maxInstance = 0;
for (int i = 0; i <= maxIntensity; ++i) {
if (intensityCount[i] > maxInstance) {
chosenIntensity = (byte)i;
maxInstance = intensityCount[i];
}
}
// TODO: correct handling of alpha values?
byte R = (byte)(avgRed[chosenIntensity] / maxInstance);
byte G = (byte)(avgGreen[chosenIntensity] / maxInstance);
byte B = (byte)(avgBlue[chosenIntensity] / maxInstance);
byte A = (byte)(avgAlpha[chosenIntensity] / maxInstance);
*dstPtr = ColorBgra.FromBgra (B, G, R, A);
//.........这里部分代码省略.........
示例13: RenderLine
protected unsafe override void RenderLine (ISurface src, ISurface dst, Rectangle rect)
{
float twist = amount;
float hw = dst.Width / 2.0f;
float hh = dst.Height / 2.0f;
float maxrad = Math.Min (hw, hh);
twist = twist * twist * Math.Sign (twist);
int aaLevel = antialias;
int aaSamples = aaLevel * aaLevel + 1;
PointD* aaPoints = stackalloc PointD[aaSamples];
for (int i = 0; i < aaSamples; ++i) {
PointD pt = new PointD (
((i * aaLevel) / (float)aaSamples),
i / (float)aaSamples);
pt.X -= (int)pt.X;
aaPoints[i] = pt;
}
for (int y = rect.Top; y <= rect.Bottom; y++) {
float j = y - hh;
ColorBgra* dstPtr = dst.GetPointAddress (rect.Left, y);
ColorBgra* srcPtr = src.GetPointAddress (rect.Left, y);
for (int x = rect.Left; x <= rect.Right; x++) {
float i = x - hw;
if (i * i + j * j > (maxrad + 1) * (maxrad + 1)) {
*dstPtr = *srcPtr;
} else {
int b = 0;
int g = 0;
int r = 0;
int a = 0;
for (int p = 0; p < aaSamples; ++p) {
float u = i + (float)aaPoints[p].X;
float v = j + (float)aaPoints[p].Y;
double rad = Math.Sqrt (u * u + v * v);
double theta = Math.Atan2 (v, u);
double t = 1 - rad / maxrad;
t = (t < 0) ? 0 : (t * t * t);
theta += (t * twist) / 100;
ColorBgra sample = src.GetPoint (
(int)(hw + (float)(rad * Math.Cos (theta))),
(int)(hh + (float)(rad * Math.Sin (theta))));
b += sample.B;
g += sample.G;
r += sample.R;
a += sample.A;
}
*dstPtr = ColorBgra.FromBgra (
(byte)(b / aaSamples),
(byte)(g / aaSamples),
(byte)(r / aaSamples),
(byte)(a / aaSamples));
}
++dstPtr;
++srcPtr;
}
}
}
示例14: RenderClouds
private unsafe static void RenderClouds (ISurface surface, Rectangle rect, int scale, byte seed, double power, ColorBgra colorFrom, ColorBgra colorTo)
{
int w = surface.Width;
int h = surface.Height;
for (int y = rect.Top; y <= rect.Bottom; ++y) {
ColorBgra* ptr = surface.GetPointAddress (rect.Left, y);
int dy = 2 * y - h;
for (int x = rect.Left; x <= rect.Right; ++x) {
int dx = 2 * x - w;
double val = 0;
double mult = 1;
int div = scale;
for (int i = 0; i < 12 && mult > 0.03 && div > 0; ++i) {
double dxr = 65536 + (double)dx / (double)div;
double dyr = 65536 + (double)dy / (double)div;
int dxd = (int)dxr;
int dyd = (int)dyr;
dxr -= dxd;
dyr -= dyd;
double noise = Noise (
unchecked ((byte)dxd),
unchecked ((byte)dyd),
dxr, //(double)dxr / div,
dyr, //(double)dyr / div,
(byte)(seed ^ i));
val += noise * mult;
div /= 2;
mult *= power;
}
*ptr = ColorBgra.Lerp (colorFrom, colorTo, (val + 1) / 2);
++ptr;
}
}
}
示例15: RenderLine
protected unsafe override void RenderLine (ISurface src, ISurface dst, Rectangle rect)
{
if (amount == 0) {
// Copy src to dest
return;
}
var src_bounds = src.Bounds;
long w = dst.Width;
long h = dst.Height;
long fox = (long)(dst.Width * offset.X * 32768.0);
long foy = (long)(dst.Height * offset.Y * 32768.0);
long fcx = fox + (w << 15);
long fcy = foy + (h << 15);
long fz = amount;
const int n = 64;
for (int y = rect.Top; y <= rect.Bottom; ++y) {
ColorBgra* dstPtr = dst.GetPointAddress (rect.Left, y);
ColorBgra* srcPtr = src.GetPointAddress (rect.Left, y);
for (int x = rect.Left; x <= rect.Right; ++x) {
long fx = (x << 16) - fcx;
long fy = (y << 16) - fcy;
int sr = 0;
int sg = 0;
int sb = 0;
int sa = 0;
int sc = 0;
sr += srcPtr->R * srcPtr->A;
sg += srcPtr->G * srcPtr->A;
sb += srcPtr->B * srcPtr->A;
sa += srcPtr->A;
++sc;
for (int i = 0; i < n; ++i) {
fx -= ((fx >> 4) * fz) >> 10;
fy -= ((fy >> 4) * fz) >> 10;
int u = (int)(fx + fcx + 32768 >> 16);
int v = (int)(fy + fcy + 32768 >> 16);
if (src_bounds.Contains (u, v)) {
ColorBgra* srcPtr2 = src.GetPointAddress (u, v);
sr += srcPtr2->R * srcPtr2->A;
sg += srcPtr2->G * srcPtr2->A;
sb += srcPtr2->B * srcPtr2->A;
sa += srcPtr2->A;
++sc;
}
}
if (sa != 0) {
*dstPtr = ColorBgra.FromBgra (
Utility.ClampToByte (sb / sa),
Utility.ClampToByte (sg / sa),
Utility.ClampToByte (sr / sa),
Utility.ClampToByte (sa / sc));
} else {
dstPtr->Bgra = 0;
}
++srcPtr;
++dstPtr;
}
}
}