public void GetChannels(float x, float[] v, int m = 0) { int W = Data.GetWidth(m); x *= (W - 1); if (Interpolation == TEXTURE_INTERPOLATION.BILINEAR) { BilinearIndex ix = NewBilinearIndex(x, W); for (int c = 0; c < Data.Channels; c++) { v[c] = GetBilinear(ix, c, m); } } else if (Interpolation == TEXTURE_INTERPOLATION.BICUBIC) { BicubicIndex ix = NewBicubicIndex(x, W); for (int c = 0; c < Data.Channels; c++) { v[c] = GetBicubic(ix, c, m); } } else { GetChannels((int)x, v, m); } }
public float GetChannel(float x, int c, int m = 0) { if (c >= Data.Channels) { return(0); } int W = Data.GetWidth(m); x *= (W - 1); if (Interpolation == TEXTURE_INTERPOLATION.BILINEAR) { BilinearIndex ix = NewBilinearIndex(x, W); return(GetBilinear(ix, c, m)); } else if (Interpolation == TEXTURE_INTERPOLATION.BICUBIC) { BicubicIndex ix = NewBicubicIndex(x, W); return(GetBicubic(ix, c, m)); } else { return(GetChannel((int)x, c, m)); } }
public void GetChannels(float x, float y, float[] v, int m = 0) { int W = GetWidth(m); int H = GetHeight(m); x *= (W - 1); y *= (H - 1); if (Interpolation == TEXTURE_INTERPOLATION.BILINEAR) { BilinearIndex ix = NewBilinearIndex(x, W); BilinearIndex iy = NewBilinearIndex(y, H); for (int c = 0; c < Channels; c++) { v[c] = GetBilinear(ix, iy, c, m); } } else if (Interpolation == TEXTURE_INTERPOLATION.BICUBIC) { BicubicIndex ix = NewBicubicIndex(x, W); BicubicIndex iy = NewBicubicIndex(y, H); for (int c = 0; c < Channels; c++) { v[c] = GetBicubic(ix, iy, c, m); } } else { GetChannels((int)x, (int)y, v, m); } }
public float GetChannel(float x, float y, int c, int m = 0) { if (c >= Channels) { return(0); } int W = GetWidth(m); int H = GetHeight(m); x *= (W - 1); y *= (H - 1); if (Interpolation == TEXTURE_INTERPOLATION.BILINEAR) { BilinearIndex ix = NewBilinearIndex(x, W); BilinearIndex iy = NewBilinearIndex(y, H); return(GetBilinear(ix, iy, c, m)); } else if (Interpolation == TEXTURE_INTERPOLATION.BICUBIC) { BicubicIndex ix = NewBicubicIndex(x, W); BicubicIndex iy = NewBicubicIndex(y, H); return(GetBicubic(ix, iy, c, m)); } else { return(GetChannel((int)x, (int)y, c, m)); } }
private float GetBicubic(BicubicIndex x, BicubicIndex y, int c, int m) { float fx, fy, v0, v1, v2, v3; fx = x.fi; fy = y.fi; v0 = Data[x.i0, y.i0, c, m]; v1 = Data[x.i1, y.i0, c, m]; v2 = Data[x.i2, y.i0, c, m]; v3 = Data[x.i3, y.i0, c, m]; float v00 = Bicubic(fx, v0, v1, v2, v3); v0 = Data[x.i0, y.i1, c, m]; v1 = Data[x.i1, y.i1, c, m]; v2 = Data[x.i2, y.i1, c, m]; v3 = Data[x.i3, y.i1, c, m]; float v01 = Bicubic(fx, v0, v1, v2, v3); v0 = Data[x.i0, y.i2, c, m]; v1 = Data[x.i1, y.i2, c, m]; v2 = Data[x.i2, y.i2, c, m]; v3 = Data[x.i3, y.i2, c, m]; float v02 = Bicubic(fx, v0, v1, v2, v3); v0 = Data[x.i0, y.i3, c, m]; v1 = Data[x.i1, y.i3, c, m]; v2 = Data[x.i2, y.i3, c, m]; v3 = Data[x.i3, y.i3, c, m]; float v03 = Bicubic(fx, v0, v1, v2, v3); return(Bicubic(fy, v00, v01, v02, v03)); }
public ColorRGBA GetPixel(float x, float y, int m = 0) { int W = GetWidth(m); int H = GetHeight(m); x *= (W - 1); y *= (H - 1); ColorRGBA pixel = new ColorRGBA(); if (Interpolation == TEXTURE_INTERPOLATION.BILINEAR) { BilinearIndex ix = NewBilinearIndex(x, W); BilinearIndex iy = NewBilinearIndex(y, H); int channels = Channels; if (channels > 0) { pixel.r = GetBilinear(ix, iy, 0, m); } if (channels > 1) { pixel.g = GetBilinear(ix, iy, 1, m); } if (channels > 2) { pixel.b = GetBilinear(ix, iy, 2, m); } if (channels > 3) { pixel.a = GetBilinear(ix, iy, 3, m); } } else if (Interpolation == TEXTURE_INTERPOLATION.BICUBIC) { BicubicIndex ix = NewBicubicIndex(x, W); BicubicIndex iy = NewBicubicIndex(y, H); int channels = Channels; if (channels > 0) { pixel.r = GetBicubic(ix, iy, 0, m); } if (channels > 1) { pixel.g = GetBicubic(ix, iy, 1, m); } if (channels > 2) { pixel.b = GetBicubic(ix, iy, 2, m); } if (channels > 3) { pixel.a = GetBicubic(ix, iy, 3, m); } } else { pixel = GetPixel((int)x, (int)y, m); } return(pixel); }