about summary refs log tree commit diff
path: root/src/tools/dilate.cpp
diff options
context:
space:
mode:
authorTeetime <anton.tsoulos@yahoo.de>2011-10-08 14:44:36 +0200
committerTeetime <anton.tsoulos@yahoo.de>2011-10-08 14:44:36 +0200
commit093a562302af1572132a2b8b7fa827f98f65a961 (patch)
tree66d54dde5164c8884832096030e22afca0c8f4c7 /src/tools/dilate.cpp
parentde7c2a5f47cc1c854e6210ba056888e7a7ae7a08 (diff)
parent50edfd37c0ed57ff793b79d06edd0bde1f6cf1bd (diff)
downloadzcatch-093a562302af1572132a2b8b7fa827f98f65a961.tar.gz
zcatch-093a562302af1572132a2b8b7fa827f98f65a961.zip
Merge branch 'master' of github.com:Teetime/teeworlds into zcatch
Diffstat (limited to 'src/tools/dilate.cpp')
-rw-r--r--src/tools/dilate.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/tools/dilate.cpp b/src/tools/dilate.cpp
index ef862270..eb770a90 100644
--- a/src/tools/dilate.cpp
+++ b/src/tools/dilate.cpp
@@ -48,18 +48,18 @@ static void CopyAlpha(int w, int h, CPixel *pSrc, CPixel *pDest)
 			pDest[m].a = pSrc[m].a;
 }
 
-int main(int argc, char **argv)
+int DilateFile(const char *pFileName)
 {
 	png_t Png;
 	CPixel *pBuffer[3] = {0,0,0};
 
 	png_init(0, 0);
-	png_open_file(&Png, argv[1]);
+	png_open_file(&Png, pFileName);
 
 	if(Png.color_type != PNG_TRUECOLOR_ALPHA)
 	{
-		dbg_msg("dilate", "not an RGBA image");
-		return -1;
+		dbg_msg("dilate", "%s: not an RGBA image", pFileName);
+		return 1;
 	}
 
 	pBuffer[0] = (CPixel*)mem_alloc(Png.width*Png.height*sizeof(CPixel), 1);
@@ -81,9 +81,23 @@ int main(int argc, char **argv)
 	CopyAlpha(w, h, pBuffer[0], pBuffer[1]);
 
 	// save here
-	png_open_file_write(&Png, argv[1]);
+	png_open_file_write(&Png, pFileName);
 	png_set_data(&Png, w, h, 8, PNG_TRUECOLOR_ALPHA, (unsigned char *)pBuffer[1]);
 	png_close_file(&Png);
 
 	return 0;
 }
+
+int main(int argc, const char **argv)
+{
+	dbg_logger_stdout();
+	if(argc == 1)
+	{
+		dbg_msg("Usage", "%s FILE1 [ FILE2... ]", argv[0]);
+		return -1;
+	}
+	
+	for(int i = 1; i < argc; i++)
+		DilateFile(argv[i]);
+	return 0;
+}