static void get_bw_scanline (guchar *bw, guchar *bgra0, guchar *bgra1, int width) { int i; for (i = 0; i < width; i++) { guchar *b = NULL; guchar *d = NULL, *e = NULL; if (i < width - 1) b = bgra0 + 4; if (bgra1) { if (i > 0) d = bgra1 - 4; if (i < width - 1) e = bgra1 + 4; } if (floyd_steinberg_dither (bgra0, b, bgra1, d, e)) bw[i/8] |= 1 << (7 - (i % 8)); bgra0 += 4; if (bgra1) bgra1 += 4; } }
bool ZLEwlImageManager::convertImageDirect(const std::string &stringData, ZLImageData &data) const { unsigned char m0, m1; m0 = *(stringData.data()); m1 = *(stringData.data()+1); if((m0 == 0xff) && (m1 == 0xd8)) convertImageDirectJpeg(stringData, data); else if(!png_sig_cmp((unsigned char *)stringData.data(), (png_size_t)0, 4) ) convertImageDirectPng(stringData, data); else if(!strncmp(stringData.c_str(), "GIF", 3)) convertImageDirectGif(stringData, data); else if(!strncmp(stringData.c_str(), "BM", 2)) convertImageDirectBmp(stringData, data); else { /* printf("unsupported image format: %d %d\n", m0, m1); FILE *f; f = fopen("/tmp/unknown_img", "w+"); fwrite(stringData.data(), 1, stringData.length(), f); fclose(f); printf("image dumped to /tmp/unknown_img\n"); */ data.init(10, 10); bzero(((ZLEwlImageData&)data).getImageData(), 25); return false; } ZLIntegerOption myDitherAlgo(ZLCategoryKey::LOOK_AND_FEEL, "Options", "DitherAlgo", 0); if(myDitherAlgo.value() == 2) floyd_steinberg_dither(data); return true; }