diff options
author | mrwastl <mrwastl@users.sourceforge.net> | 2013-03-21 20:29:45 +0100 |
---|---|---|
committer | mrwastl <mrwastl@users.sourceforge.net> | 2013-03-21 20:29:45 +0100 |
commit | 60bdec72ecd6bb236f2f1153398c9996fb95730f (patch) | |
tree | 7b6a7667f41002b54dcc78360cef71256b811c94 /glcdgraphics/glcd.c | |
parent | cf926629084ab015873859e759155f9bfe813e6b (diff) | |
download | graphlcd-base-60bdec72ecd6bb236f2f1153398c9996fb95730f.tar.gz graphlcd-base-60bdec72ecd6bb236f2f1153398c9996fb95730f.tar.bz2 |
glcdgraphics: bug fix in glcd.c, moved methods Scale() and Blend() to image.c, added static methods for loading/saving image; showpic and convpic working again; convpic cleaned up; showpic: added parameters for scaling and centering image
Diffstat (limited to 'glcdgraphics/glcd.c')
-rw-r--r-- | glcdgraphics/glcd.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/glcdgraphics/glcd.c b/glcdgraphics/glcd.c index 3b2c3f3..6e97208 100644 --- a/glcdgraphics/glcd.c +++ b/glcdgraphics/glcd.c @@ -10,7 +10,7 @@ * to the COPYING file distributed with this package. * * (c) 2004-2010 Andreas Regel <andreas.regel AT powarman.de> - * (c) 2010-2011 Wolfgang Astleitner <mrwastl AT users sourceforge net> + * (c) 2010-2013 Wolfgang Astleitner <mrwastl AT users sourceforge net> * Andreas 'randy' Weinberger */ @@ -69,7 +69,7 @@ bool cGLCDFile::Load(cImage & image, const string & fileName) fp = fopen(fileName.c_str(), "rb"); if (!fp) { - syslog(LOG_ERR, "glcdgraphics: open %s failed (cGLCDFile::Load).", fileName.c_str()); + syslog(LOG_ERR, "glcdgraphics: opening of '%s' failed (cGLCDFile::Load).", fileName.c_str()); return false; } @@ -98,7 +98,7 @@ bool cGLCDFile::Load(cImage & image, const string & fileName) // check header sign if (strncmp(sign, kGLCDFileSign, 3) != 0) { - syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong header (cGLCDFile::Load).", fileName.c_str()); + syslog(LOG_ERR, "glcdgraphics: loading of '%s' failed, wrong header (cGLCDFile::Load).", fileName.c_str()); fclose(fp); return false; } @@ -114,7 +114,7 @@ bool cGLCDFile::Load(cImage & image, const string & fileName) height = (buf[3] << 8) | buf[2]; if (width == 0 || height == 0) { - syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong header (cGLCDFile::Load).", fileName.c_str()); + syslog(LOG_ERR, "glcdgraphics: loading of '%s' failed, wrong header (cGLCDFile::Load).", fileName.c_str()); fclose(fp); return false; } @@ -126,7 +126,7 @@ bool cGLCDFile::Load(cImage & image, const string & fileName) // check file length if (fileSize != (long) (height * ((width + 7) / 8) + 8)) { - syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong size (cGLCDFile::Load).", fileName.c_str()); + syslog(LOG_ERR, "glcdgraphics: loading of '%s' failed, wrong size (cGLCDFile::Load).", fileName.c_str()); fclose(fp); return false; } @@ -136,7 +136,7 @@ bool cGLCDFile::Load(cImage & image, const string & fileName) // read count and delay if (fread(buf, 6, 1, fp) != 1) { - syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong header (cGLCDFile::Load).", fileName.c_str()); + syslog(LOG_ERR, "glcdgraphics: loading of '%s' failed, wrong header (cGLCDFile::Load).", fileName.c_str()); fclose(fp); return false; } @@ -146,7 +146,7 @@ bool cGLCDFile::Load(cImage & image, const string & fileName) if (count == 0 || fileSize != (long) (count * (height * ((width + 7) / 8)) + 14)) { - syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong size (cGLCDFile::Load).", fileName.c_str()); + syslog(LOG_ERR, "glcdgraphics: loading of '%s' failed, wrong size (cGLCDFile::Load).", fileName.c_str()); fclose(fp); return false; } @@ -156,7 +156,7 @@ bool cGLCDFile::Load(cImage & image, const string & fileName) } else { - syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong header (cGLCDFile::Load).", fileName.c_str()); + syslog(LOG_ERR, "glcdgraphics: loading of '%s' failed, wrong header (cGLCDFile::Load).", fileName.c_str()); fclose(fp); return false; } @@ -213,7 +213,7 @@ bool cGLCDFile::Load(cImage & image, const string & fileName) if (bmpdata_raw) delete[] bmpdata_raw; - syslog(LOG_DEBUG, "glcdgraphics: image %s loaded.", fileName.c_str()); + syslog(LOG_DEBUG, "glcdgraphics: image '%s' loaded.", fileName.c_str()); return true; } @@ -234,7 +234,7 @@ bool cGLCDFile::Save(cImage & image, const string & fileName) fp = fopen(fileName.c_str(), "wb"); if (!fp) { - syslog(LOG_ERR, "glcdgraphics: open %s failed (cGLCDFile::Save).", fileName.c_str()); + syslog(LOG_ERR, "glcdgraphics: opening '%s' failed (cGLCDFile::Save).", fileName.c_str()); return false; } @@ -285,8 +285,7 @@ bool cGLCDFile::Save(cImage & image, const string & fileName) { if (bitmap->Width() == width && bitmap->Height() == height) { -// if (fwrite(bitmap->Data(), height * ((width + 7) / 8), 1, fp) != 1) - if (fwrite(bitmap->Data(), height * width, 1, fp) != 1) + if (fwrite( cBitmap::ConvertTo1BPP(*bitmap), height * ((width + 7) / 8), 1, fp) != 1) { fclose(fp); return false; @@ -296,7 +295,7 @@ bool cGLCDFile::Save(cImage & image, const string & fileName) } fclose(fp); - syslog(LOG_DEBUG, "glcdgraphics: image %s saved.", fileName.c_str()); + syslog(LOG_DEBUG, "glcdgraphics: image '%s' saved.", fileName.c_str()); return true; } |