Index: trunk/src/image/png_writer.cc
===================================================================
--- trunk/src/image/png_writer.cc	(revision 535)
+++ trunk/src/image/png_writer.cc	(revision 551)
@@ -12,5 +12,5 @@
 #include <stdarg.h>  
 
-using namespace nv;
+//using namespace nv;
 
 #if NV_COMPILER == NV_CLANG
@@ -33,8 +33,8 @@
 };
 
-#define STBI_MALLOC(sz)     nvmalloc(sz)
-#define STBI_REALLOC(p,sz)  nvrealloc(p,sz)
-#define STBI_FREE(p)        nvfree(p)
-#define STBI_MEMMOVE(d,s,c) nvmemmove(d,s,c)
+#define STBI_MALLOC(sz)     nv::nvmalloc(sz)
+#define STBI_REALLOC(p,sz)  nv::nvrealloc(p,sz)
+#define STBI_FREE(p)        nv::nvfree(p)
+#define STBI_MEMMOVE(d,s,c) nv::nvmemmove(d,s,c)
 
 typedef void stbi_write_func( void *context, void *data, int size );
@@ -57,7 +57,7 @@
 
 template < typename T >
-inline uchar8 byte_cast( T x )
-{
-	return uchar8( ( x ) & 255 );
+inline nv::uchar8 byte_cast( T x )
+{
+	return nv::uchar8( ( x ) & 255 );
 }
 
@@ -246,7 +246,12 @@
 }
 
+static int iabs( int i )
+{
+	return i >= 0 ? i : -i;
+}
+
 static unsigned char stbiw__paeth( int a, int b, int c )
 {
-	int p = a + b - c, pa = abs( p - a ), pb = abs( p - b ), pc = abs( p - c );
+	int p = a + b - c, pa = iabs( p - a ), pb = iabs( p - b ), pc = iabs( p - c );
 	if ( pa <= pb && pa <= pc ) return byte_cast( a );
 	if ( pb <= pc ) return byte_cast( b );
@@ -320,5 +325,5 @@
 				if ( p ) break;
 				for ( i = 0; i < x*n; ++i )
-					est += abs( (signed char)line_buffer[i] );
+					est += iabs( (signed char)line_buffer[i] );
 				if ( est < bestval ) { bestval = est; best = k; }
 			}
