george82 | 01f7687 | 2006-03-28 14:22:56 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2006 TightVNC Team. All Rights Reserved. |
| 2 | * |
| 3 | * This is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This software is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this software; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 16 | * USA. |
| 17 | * |
| 18 | * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | // -=- ScaledDIBSectionBuffer.cxx |
| 23 | |
| 24 | #include <math.h> |
| 25 | |
| 26 | #include <rfb_win32/ScaledDIBSectionBuffer.h> |
| 27 | |
| 28 | using namespace rfb; |
| 29 | using namespace win32; |
| 30 | |
| 31 | ScaledDIBSectionBuffer::ScaledDIBSectionBuffer(HWND window) |
| 32 | : DIBSectionBuffer(window) { |
| 33 | scaled_data = data; |
| 34 | } |
| 35 | |
| 36 | void ScaledDIBSectionBuffer::setSrcPixelBuffer(U8 **src_data_, int w, int h, PixelFormat pf) { |
| 37 | src_data = src_data_; |
| 38 | src_width = w; |
| 39 | src_height = h; |
| 40 | scaled_width = width_ = (int)ceil(src_width * scale_ratio); |
| 41 | scaled_height = height_ = (int)ceil(src_height * scale_ratio); |
| 42 | setPF(pf); //recreateScaledBuffer() was run |
| 43 | } |
| 44 | |
| 45 | void ScaledDIBSectionBuffer::setPF(const PixelFormat &pf) { |
| 46 | DIBSectionBuffer::setPF(pf); |
| 47 | scaled_data = data; |
| 48 | } |
| 49 | |
| 50 | void ScaledDIBSectionBuffer::setSize(int src_width_, int src_height_) { |
| 51 | src_width = src_width_; |
| 52 | src_height = src_height_; |
| 53 | setScale(scale_ratio * 100); |
| 54 | } |
| 55 | |
| 56 | void ScaledDIBSectionBuffer::recreateScaledBuffer() { |
| 57 | width_ = scaled_width; |
| 58 | height_ = scaled_height; |
george82 | 66f93dc | 2006-03-28 15:09:38 +0000 | [diff] [blame^] | 59 | DIBSectionBuffer::recreateBuffer(); |
george82 | 01f7687 | 2006-03-28 14:22:56 +0000 | [diff] [blame] | 60 | scaled_data = data; |
| 61 | } |