ScaledPixelBuffer::ScaledPixelBuffer(U8 **src_data_, int src_width_,
int src_height_, int scale, PixelFormat pf_)
- : scaled_data(0), scale_ratio(1), scale(100) {
+ : scaled_data(0), scale_ratio(1) {
setSourceBuffer(src_data_, src_width_, src_height_);
setPF(pf_);
}
ScaledPixelBuffer::ScaledPixelBuffer()
- : src_data(0), src_width(0), src_height(0), scale_ratio(1), scale(100),
+ : src_data(0), src_width(0), src_height(0), scale_ratio(1),
pf(PixelFormat(32,24,0,1,255,255,255,0,8,16)), scaled_data(0) {
}
pf = pf_;
}
-void ScaledPixelBuffer::setScale(int scale_) {
- if (scale != scale_) {
- scale = scale_;
- scale_ratio = double(scale) / 100;
+void ScaledPixelBuffer::setScaleRatio(double scale_ratio_) {
+ if (scale_ratio != scale_ratio_) {
+ scale_ratio = scale_ratio_;
calculateScaledBufferSize();
}
}
int getSrcWidth() const { return src_width; }
int getSrcHeight() const { return src_height; }
int area() const { return scaled_width * scaled_height; }
- int getScale() const { return scale; }
+ int getScale() const { return int(scale_ratio + 0.5); }
+ double getScaleRatio() const { return scale_ratio; }
// Get rectangle encompassing this buffer
// Top-left of rectangle is either at (0,0), or the specified point.
void setPF(const PixelFormat &pf);
// Set the new scale, in percent
- virtual void setScale(int scale);
+ virtual void setScale(int scale) { setScaleRatio(double(scale)/100.0); }
+ virtual void setScaleRatio(double scale_ratio);
// Scale rect from the source image buffer to the destination buffer
// using bilinear interpolation
int scaled_width;
int scaled_height;
PixelFormat pf;
- int scale;
double scale_ratio;
U8 **src_data;
U8 *scaled_data;