virtual BOOL on_draw(HELEMENT he, UINT draw_type, HDC hdc, const RECT &rc) { if ((DRAW_EVENTS)draw_type != where) return FALSE; // do default draw int w = rc.right - rc.left; int h = rc.bottom - rc.top; if (!surface) { surface = image::create(w, h); redraw = true; } else if (w != surface->width() || h != surface->height()) { delete surface; surface = image::create(w, h); redraw = true; } else if (redraw) surface->clear(); if (redraw) { graphics gx(surface); draw(he, gx, w, h); redraw = false; } surface->blit(hdc, rc.left, rc.top); return default_draw ? TRUE : FALSE; }
static std::vector<double> decompress(image in){ auto width = in.header.width; auto height = in.header.height; assert(is_pow_of_two(width)); assert(is_pow_of_two(height)); auto q = in.header.get_quantization(quantization::type::logarithmic); std::vector<double> image(width * height, 0.0); // read in coefficient on coordinates for(auto it = in.data.begin(); it != in.data.end(); ++it){ auto&& x = *it; image[x.x + width*x.y] = q.backwards(x.c); } in.clear(); // inverse wavelet transform in y-direction for(unsigned int i = 0; i < width; ++i){ unwavelet(&image[i], height, width); } // inverse wavelet transform in x-direction for(unsigned int i = 0; i < height; ++i){ unwavelet(&image[i*width], width, 1); } return image; }