Last time we studied the "image processing" needed it was a dumb "bilinear filtering"
You need a good half-day to code this from zero you should find plenty of "managed" code library to do it for you
System.Drawing.Bitmap m_bmp = DevIL.DevIL.LoadBitmap(path);
for (int y = 0; y < 255; y++)
{
for (int x = 0; x < 255; x++)
{
ValueOffset[x, y] = m_bmp.GetPixel(x, y).R;
}
}
i'm plaing on ywain at times. they still have lots of their own problems with pathing, pet los, and allStill waiting for you old bud
m_crc.Value = (long)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]);
m_sizeDir = ((buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7]);
m_sizeName = ((buf[8] << 24) | (buf[9] << 16) | (buf[10] << 8) | buf[11]);
m_numFiles = ((buf[12] << 24) | (buf[13] << 16) | (buf[14] << 8) | buf[15]);
m_crc.Value = (long)((buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]);
m_sizeDir = ((buf[7] << 24) | (buf[6] << 16) | (buf[5] << 8) | buf[4]);
m_sizeName = ((buf[11] << 24) | (buf[10] << 16) | (buf[9] << 8) | buf[8]);
m_numFiles = ((buf[15] << 24) | (buf[14] << 16) | (buf[13] << 8) | buf[12]);
#region Z
private bool m_zActive = false;
public bool zActive
{
get { return m_zActive; }
}
private byte[,] m_zoneTerrain;
private byte[,] m_zoneOffset;
private byte m_scalefactor;
private byte m_offsetfactor;
public int getZ(int X, int Y)
{
if (!m_zActive || m_zoneTerrain == null || m_zoneOffset == null) return 0; // In case of error you COULD return -1 and handle all the problems...
try
{
int x = X - XOffset; // EDIT: Sorry, forgot to restore after fix
int y = Y - YOffset;
if (x < 0 || x > 65535 || y < 0 || y > 65535)
{
//log.Error(string.Format("ZMgr: Value either too big or too low! X:{0} Y:{1} ZoneID:{2}", x, y, ZoneID));
return 0;
}
int sx = x >> 8;
int sy = y >> 8;
double ox = x / 256.0f - sx;
double oy = y / 256.0f - sy;
if (ox + oy < 1) //Check the position of the point: we are going to use math to convert a 256x256 matrix to a 65kx65k! yay math!
{
//Top triangle
int h_xy = getZonePointHeight(sx, sy);
int h_x1y = getZonePointHeight(sx + 1, sy);
int h_xy1 = getZonePointHeight(sx, sy + 1);
return (int)(h_xy + (h_x1y - h_xy) * ox + (h_xy1 - h_xy) * oy);
}
else
{
//Bottom triangle
int h_x1y = getZonePointHeight(sx + 1, sy);
int h_xy1 = getZonePointHeight(sx, sy + 1);
int h_x1y1 = getZonePointHeight(sx + 1, sy + 1);
return (int)(h_x1y1 + (h_xy1 - h_x1y1) * (1.0 - ox) + (h_x1y - h_x1y1) * (1.0 - oy));
}
}
catch (Exception ex)
{
//DOL.Promise.Mail.SendMail("nydirac@gmail.com", "Z Exception", ex.Message + " ---------> " + ex.StackTrace);
return 0;
}
}
private int getZonePointHeight(int X, int Y) //Raw data from the terrain data
{
if (X > 255 || X < 0 || Y > 255 || Y < 0) // In case of freak accident, better to be safe than sorry...
{
//log.Warn("GetZonePointHeight error! X: " + X + " Y: " + Y + " ZoneID: " + ZoneID);
return 0;
}
return (m_zoneTerrain[X,Y] * m_scalefactor + m_zoneOffset[X, Y] * m_offsetfactor);
}
#endregion
Return to “%s” DOL Development Discussion
Users browsing this forum: No registered users and 1 guest