예제 #1
0
void buf2grid(int step, agg::grid_rendering_buffer& buf) {
    std::ostringstream s("");
    s << "{ \"grid\":\n[\n";
    for (unsigned y = 0; y < buf.height(); y=y+step)
    {
        agg::grid_value* row = buf.row(y);
        s << "\"";
        for (unsigned x = 0; x < buf.width(); x=x+step)
        {
            //s << "'" << (int)row[x] << "'";
            
            agg::grid_value val = (agg::grid_value)row[x];
            if (val == 0)
              s << " ";
            else 
              s << val;
            
            //s << (int)row[x*4];
            //s << row[x];
        }
        s << "\",\n";
    }
    s << "]\n}";
    std::clog << s.str() << "\n";
}
예제 #2
0
std::wstring buf2grid_as_string(int step, agg::grid_rendering_buffer& buf) {
    std::wostringstream s(L"");
	
	s << "\"grid\":[";
    for (unsigned y = 0; y < buf.height(); y=y+step)
    {
        agg::grid_value* row = buf.row(y);
        s << "\"";
        for (unsigned x = 0; x < buf.width(); x=x+step)	
        {
			agg::grid_value val = (agg::grid_value)row[x];
			if (val < 0) {
				s << " ";}
			else {
				s << val;
			}
        }

         s << "\"";
		if(y < buf.height()-step) {
			s << ",";
		}
    }
	s << "]";
	
	return  s.str();
}