boolean faSizeNext(struct lineFile *lf, char retLine[512], int *retSize) /* Get > line and size for next fa record. Return FALSE at end of file. */ { char *line; int size = 0; /* Fetch first record . */ for (;;) { if (!lineFileNext(lf, &line, NULL)) return FALSE; if (line[0] == '>') break; } strncpy(retLine, line, 512); /* Loop around counting DNA-looking characters until next record. */ for (;;) { if (!lineFileNext(lf, &line, NULL)) break; if (line[0] == '>') { lineFileReuse(lf); break; } size += alphaCount(line); } *retSize = size; return TRUE; }
void reduce_4(T const& in, image_gray8 & out, octree<rgb> trees[], unsigned limits[], unsigned levels, std::vector<unsigned> & alpha) { unsigned width = in.width(); unsigned height = in.height(); std::vector<unsigned> alphaCount(alpha.size()); for(unsigned i=0; i<alpha.size(); i++) { alpha[i] = 0; alphaCount[i] = 0; } for (unsigned y = 0; y < height; ++y) { mapnik::image_rgba8::pixel_type const * row = in.get_row(y); mapnik::image_gray8::pixel_type * row_out = out.get_row(y); for (unsigned x = 0; x < width; ++x) { unsigned val = row[x]; std::uint8_t index = 0; int idx=-1; for(int j=levels-1; j>0; j--) { if (U2ALPHA(val)>=limits[j] && trees[j].colors()>0) { index = idx = trees[j].quantize(val); break; } } if (idx>=0 && idx < static_cast<int>(alpha.size())) { alpha[idx]+=U2ALPHA(val); alphaCount[idx]++; } if (x%2 == 0) { index = index<<4; } row_out[x>>1] |= index; } } for(unsigned i=0; i<alpha.size(); i++) { if (alphaCount[i]!=0) { alpha[i] /= alphaCount[i]; } } }
void reduce_4 (T const& in, image_data_8 & out, octree<rgb> trees[], unsigned limits[], unsigned levels, std::vector<unsigned> & alpha) { unsigned width = in.width(); unsigned height = in.height(); //unsigned alphaCount[alpha.size()]; std::vector<unsigned> alphaCount(alpha.size()); for(unsigned i=0; i<alpha.size(); i++) { alpha[i] = 0; alphaCount[i] = 0; } for (unsigned y = 0; y < height; ++y) { mapnik::image_data_32::pixel_type const * row = in.getRow(y); mapnik::image_data_8::pixel_type * row_out = out.getRow(y); for (unsigned x = 0; x < width; ++x) { unsigned val = row[x]; mapnik::rgb c(U2RED(val), U2GREEN(val), U2BLUE(val)); byte index = 0; int idx=-1; for(int j=levels-1; j>0; j--){ if (U2ALPHA(val)>=limits[j] && trees[j].colors()>0) { index = idx = trees[j].quantize(c); break; } } if (idx>=0 && idx<(int)alpha.size()) { alpha[idx]+=U2ALPHA(val); alphaCount[idx]++; } if (x%2 == 0) index = index<<4; row_out[x>>1] |= index; } } for(unsigned i=0; i<alpha.size(); i++) { if (alphaCount[i]!=0) alpha[i] /= alphaCount[i]; } }