|
|
@ -899,3 +899,40 @@ int ncvisual_resize(ncvisual* nc, int rows, int cols){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return visual_implementation->visual_resize(nc, rows, cols);
|
|
|
|
return visual_implementation->visual_resize(nc, rows, cols);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Inflate each pixel of 'bmap' to 'scale'x'scale' pixels square, using the
|
|
|
|
|
|
|
|
// same color as the original pixel.
|
|
|
|
|
|
|
|
static inline void*
|
|
|
|
|
|
|
|
inflate_bitmap(const uint32_t* bmap, int scale, int rows, int stride, int cols){
|
|
|
|
|
|
|
|
size_t size = rows * cols * scale * scale * sizeof(*bmap);
|
|
|
|
|
|
|
|
uint32_t* ret = malloc(size);
|
|
|
|
|
|
|
|
if(ret){
|
|
|
|
|
|
|
|
for(int y = 0 ; y < rows ; ++y){
|
|
|
|
|
|
|
|
const uint32_t* src = bmap + y * (stride / sizeof(*bmap));
|
|
|
|
|
|
|
|
for(int yi = 0 ; yi < scale ; ++yi){
|
|
|
|
|
|
|
|
uint32_t* dst = ret + (y * scale + yi) * cols * scale;
|
|
|
|
|
|
|
|
for(int x = 0 ; x < cols ; ++x){
|
|
|
|
|
|
|
|
for(int xi = 0 ; xi < scale ; ++xi){
|
|
|
|
|
|
|
|
dst[x * scale + xi] = src[x];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ncvisual_inflate(ncvisual* n, int scale){
|
|
|
|
|
|
|
|
if(scale <= 0){
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void* inflaton = inflate_bitmap(n->data, scale, n->rows, n->rowstride, n->cols);
|
|
|
|
|
|
|
|
if(inflaton == NULL){
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
n->rows *= scale;
|
|
|
|
|
|
|
|
n->cols *= scale;
|
|
|
|
|
|
|
|
n->rowstride = 4 * n->cols;
|
|
|
|
|
|
|
|
ncvisual_set_data(n, inflaton, true);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|