img_destroy(&ipm);
return true;
+}
+
+Vec4 Image::lookup_nearest(float u, float v) const
+{
+ int x = (int)(u * w) % w;
+ int y = (int)(v * h) % h;
+
+ if(is_float) {
+ return ((Vec4*)pixels)[y * w + x];
+ }
+
+ Vec4 color;
+ unsigned char *pptr = ((unsigned char*)pixels) + (y * w + x) * 4;
+ color.x = pptr[0] / 255.0;
+ color.y = pptr[1] / 255.0;
+ color.z = pptr[2] / 255.0;
+ color.w = pptr[3] / 255.0;
+
+ return color;
}
\ No newline at end of file