ColorMap::ColorMap(const InterpolatedColorMap &o) { init(o.getCols(),o.getRows()); for(int row=0; row<rows; row++) for(int col=0; col<cols; col++) c[row][col] = o.get(row,col); }
void VGImage::rectangles(const Bitmap &bitmap) { double bw=bitmap.x2-bitmap.x1; double bh=bitmap.y2-bitmap.y1; Bitmap::CMType which; int w = 0, h = 0; InterpolatedColorMap icm; ColorMap cm; if(bitmap.getICM(&icm)) { which = Bitmap::ICM; w = icm.getCols(); h = icm.getRows(); } else if(bitmap.getCM(&cm)) { which = Bitmap::CM; w = cm.getCols(); h = cm.getRows(); } double dx=bw/w; double dy=bh/h; StrokeStyle ssb(Color::CLEAR); // In the future, this could create bigger boxes if adjacent rectangles // would be the same color. for(int r=(ll?0:h-1); (ll?r<h:r>=0); r+=(ll?1:-1)) { for(int c=0; c<w; c++) { double x1=bitmap.x1+c*dx; double y1=bitmap.y1+(ll?r:h-r-1)*dy; Rectangle rect(x1,y1,x1+dx,y1+dy,ssb); if(which==Bitmap::CM) rect.setFillColor(cm.get(r,c)); else rect.setFillColor(icm.get(r,c)); rectangle(rect); } } }