Originally Posted by
Thundathigh
Ah, the values I have in the Horizontal row should all become 4 then (except for 1366x768 which would become 3??). That does make a lot more sense, thanks for clearing that up!
Just to clarify; It is empty in the ss I was referring to in the quote but not at all resolutions though.
What's with 800*600? That looks like the odd one out to me...
Yes 800x600 is special.
Code:
rects.Add(new Rect(-384, 384, -220, 220)); // x_offset from center, width, y_offset from center, height
rects.Add(new Rect(0, 300, -285, 285));
rects.Add(new Rect(-340, 340, 0, 250));
rects.Add(new Rect(0, 340, 0, 250));
Update:
Watermark positioning. Not 100% perfect though. It is off by 1 pixel on the Y offset on some resolutions.
Code:
public struct Rect
{
public short X;
public short Width;
public short Y;
public short Height;
public Rect(short x, short width, short y, short height)
{
X = x;
Width = width;
Y = y;
Height = height;
}
}
Rect[] GenerateRects(int width, int height, int numBytes) // screen width, screen height, number of bytes in watermark (88 bytes)
{
List<Rect> ret = new List<Rect>();
if (width != 800 || height != 600)
{
int tmp = ((((((numBytes << 4) + (numBytes * 2)) * 3) - 1) / (numBytes * 2 * 3) * (numBytes * 2 * 3)) + 7) >> 3;
int numVerticalBits = (int)((height * 0.2325581395348837 + 4) * 0.2);
int numHorizontalBits = (int)Math.Floor((8 * tmp) / (float)(int)numVerticalBits) + 1;
if (numHorizontalBits > width)
return null;
short rheight = (short)(5 * (int)numVerticalBits);
short rwidth = (short)(4 * (int)numHorizontalBits);
if (8 * numHorizontalBits > (width - 16))
{
ret.Add(new Rect((short)Math.Floor(rwidth * -0.5), rwidth, (short)Math.Floor(rheight * -1.55), rheight));
ret.Add(new Rect((short)Math.Floor(rwidth * -0.5), rwidth, (short)Math.Floor(rheight * -0.5), rheight));
ret.Add(new Rect((short)Math.Floor(rwidth * -0.5), rwidth, (short)Math.Floor(rheight * 0.55000001), rheight));
}
else
{
int totalx = rwidth >> 1;
ret.Add(new Rect((short)-(rwidth >> 1), rwidth, (short)-(rheight >> 1), rheight));
short v10 = (short)(rwidth >> 1);
short v13;
if ((rwidth >> 1) + (rwidth + 4) < (width >> 1))
{
do
{
if (ret.Count > 30)
break;
v13 = (short)(v10 + 4);
v10 = (short)(rwidth + v13);
ret.Add(new Rect(v13, rwidth, (short)Math.Floor(rheight * -0.5), rheight));
ret.Add(new Rect((short)-v10, rwidth, (short)Math.Floor(rheight * -0.5), rheight));
} while (v10 + rwidth + 4 < (width >> 1));
}
int v15 = rwidth + 4;
int v16 = 0;
if ((rwidth + 4) < (width >> 1))
{
double v17 = 1.5;
do
{
if (ret.Count > 28)
break;
int v18 = v16 + 4;
v16 = rwidth + v18;
totalx = rwidth + v15 + 4;
ret.Add(new Rect((short)v18, rwidth, (short)(-4 - ((int)Math.Floor(rheight * v17))), rheight));
ret.Add(new Rect((short)v18, rwidth, (short)(4 - (int)Math.Floor(rheight * -0.5)), rheight));
ret.Add(new Rect((short)-(rwidth + v18), rwidth, (short)(-4 - ((int)Math.Floor(rheight * v17))), rheight));
ret.Add(new Rect((short)-(rwidth + v18), rwidth, (short)(4 - (int)Math.Floor(rheight * -0.5)), rheight));
v15 = totalx;
} while (totalx < (width >> 1));
}
}
}
else
{
ret.Add(new Rect(-384, 384, -220, 220));
ret.Add(new Rect(0, 300, -285, 285));
ret.Add(new Rect(-340, 340, 0, 250));
ret.Add(new Rect(0, 340, 0, 250));
}
return ret.ToArray();
}