1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _DXCANVAS_BITMAPCANVASHELPER_HXX_ 25 #define _DXCANVAS_BITMAPCANVASHELPER_HXX_ 26 27 #include <com/sun/star/rendering/XCanvas.hpp> 28 29 #include <basegfx/vector/b2isize.hxx> 30 #include <basegfx/vector/b2dsize.hxx> 31 32 #include "dx_graphicsprovider.hxx" 33 #include "dx_ibitmap.hxx" 34 #include "dx_gdiplususer.hxx" 35 #include "dx_impltools.hxx" 36 #include "dx_canvashelper.hxx" 37 38 #include <boost/utility.hpp> 39 40 41 namespace dxcanvas 42 { 43 /** Helper class for basic canvas functionality. Also offers 44 optional backbuffer painting, when providing it with a second 45 HDC to render into. 46 */ 47 class BitmapCanvasHelper : public CanvasHelper 48 { 49 public: 50 BitmapCanvasHelper(); 51 52 /// Release all references 53 void disposing(); 54 55 /** Set the target for rendering operations 56 57 @param rTarget 58 Render target 59 */ 60 void setTarget( const IBitmapSharedPtr& rTarget ); 61 62 /** Set the target for rendering operations 63 64 @param rTarget 65 Render target 66 67 @param rOutputOffset 68 Output offset in pixel 69 */ 70 void setTarget( const IBitmapSharedPtr& rTarget, 71 const ::basegfx::B2ISize& rOutputOffset ); 72 73 74 // CanvasHelper functionality is implementation-inherited. yuck. 75 // ============================================================= 76 void clear(); 77 78 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > 79 drawTextLayout( const ::com::sun::star::rendering::XCanvas* pCanvas, 80 const ::com::sun::star::uno::Reference< 81 ::com::sun::star::rendering::XTextLayout >& layoutetText, 82 const ::com::sun::star::rendering::ViewState& viewState, 83 const ::com::sun::star::rendering::RenderState& renderState ); 84 85 // BitmapCanvasHelper functionality 86 // ================================ 87 88 void copyRect( const ::com::sun::star::rendering::XCanvas* pCanvas, 89 const ::com::sun::star::uno::Reference< 90 ::com::sun::star::rendering::XBitmapCanvas >& sourceCanvas, 91 const ::com::sun::star::geometry::RealRectangle2D& sourceRect, 92 const ::com::sun::star::rendering::ViewState& sourceViewState, 93 const ::com::sun::star::rendering::RenderState& sourceRenderState, 94 const ::com::sun::star::geometry::RealRectangle2D& destRect, 95 const ::com::sun::star::rendering::ViewState& destViewState, 96 const ::com::sun::star::rendering::RenderState& destRenderState ); 97 98 ::com::sun::star::geometry::IntegerSize2D getSize(); 99 100 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > 101 getScaledBitmap( const ::com::sun::star::geometry::RealSize2D& newSize, 102 sal_Bool beFast ); 103 104 ::com::sun::star::uno::Sequence< sal_Int8 > 105 getData( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 106 const ::com::sun::star::geometry::IntegerRectangle2D& rect ); 107 108 void setData( const ::com::sun::star::uno::Sequence< sal_Int8 >& data, 109 const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 110 const ::com::sun::star::geometry::IntegerRectangle2D& rect ); 111 112 void setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >& color, 113 const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 114 const ::com::sun::star::geometry::IntegerPoint2D& pos ); 115 116 ::com::sun::star::uno::Sequence< sal_Int8 > 117 getPixel( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, 118 const ::com::sun::star::geometry::IntegerPoint2D& pos ); 119 120 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapPalette > getPalette(); 121 122 ::com::sun::star::rendering::IntegerBitmapLayout getMemoryLayout(); 123 124 bool hasAlpha() const; 125 126 protected: 127 /// Render target 128 IBitmapSharedPtr mpTarget; 129 }; 130 } 131 132 #endif /* _DXCANVAS_BITMAPCANVASHELPER_HXX_ */ 133