2 * Copyright (c) 2007-2010 SlimDX Group
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
5 * of this software and associated documentation files (the "Software"), to deal
\r
6 * in the Software without restriction, including without limitation the rights
\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
8 * copies of the Software, and to permit persons to whom the Software is
\r
9 * furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
25 #include <d2d1helper.h>
\r
27 #include "Direct2DException.h"
\r
29 #include "RenderTarget.h"
\r
30 #include "BitmapBrush.h"
\r
32 const IID IID_ID2D1BitmapBrush = __uuidof(ID2D1BitmapBrush);
\r
34 using namespace System;
\r
40 BitmapBrush::BitmapBrush( RenderTarget^ renderTarget, SlimDX::Direct2D::Bitmap^ bitmap )
\r
42 ID2D1BitmapBrush *brush = NULL;
\r
44 HRESULT hr = renderTarget->InternalPointer->CreateBitmapBrush( bitmap->InternalPointer, &brush );
\r
46 if( RECORD_D2D( hr ).IsFailure )
\r
47 throw gcnew Direct2DException( Result::Last );
\r
52 BitmapBrush::BitmapBrush( RenderTarget^ renderTarget, SlimDX::Direct2D::Bitmap^ bitmap, BitmapBrushProperties bitmapBrushProperties )
\r
54 ID2D1BitmapBrush *brush = NULL;
\r
56 HRESULT hr = renderTarget->InternalPointer->CreateBitmapBrush( bitmap->InternalPointer, reinterpret_cast<D2D1_BITMAP_BRUSH_PROPERTIES*>( &bitmapBrushProperties ),
\r
59 if( RECORD_D2D( hr ).IsFailure )
\r
60 throw gcnew Direct2DException( Result::Last );
\r
65 BitmapBrush::BitmapBrush( RenderTarget^ renderTarget, SlimDX::Direct2D::Bitmap^ bitmap, BitmapBrushProperties bitmapBrushProperties, BrushProperties brushProperties )
\r
67 ID2D1BitmapBrush *brush = NULL;
\r
69 HRESULT hr = renderTarget->InternalPointer->CreateBitmapBrush( bitmap->InternalPointer, reinterpret_cast<D2D1_BITMAP_BRUSH_PROPERTIES*>( &bitmapBrushProperties ),
\r
70 reinterpret_cast<D2D1_BRUSH_PROPERTIES*>( &brushProperties ), &brush );
\r
72 if( RECORD_D2D( hr ).IsFailure )
\r
73 throw gcnew Direct2DException( Result::Last );
\r
78 SlimDX::Direct2D::Bitmap^ BitmapBrush::Bitmap::get()
\r
80 ID2D1Bitmap *bitmap = NULL;
\r
81 InternalPointer->GetBitmap( &bitmap );
\r
83 return SlimDX::Direct2D::Bitmap::FromPointer( bitmap );
\r
86 void BitmapBrush::Bitmap::set( SlimDX::Direct2D::Bitmap^ value )
\r
88 InternalPointer->SetBitmap( value->InternalPointer );
\r
91 ExtendMode BitmapBrush::HorizontalExtendMode::get()
\r
93 return static_cast<ExtendMode>( InternalPointer->GetExtendModeX() );
\r
96 void BitmapBrush::HorizontalExtendMode::set( ExtendMode value )
\r
98 InternalPointer->SetExtendModeX( static_cast<D2D1_EXTEND_MODE>( value ) );
\r
101 ExtendMode BitmapBrush::VerticalExtendMode::get()
\r
103 return static_cast<ExtendMode>( InternalPointer->GetExtendModeY() );
\r
106 void BitmapBrush::VerticalExtendMode::set( ExtendMode value )
\r
108 InternalPointer->SetExtendModeY( static_cast<D2D1_EXTEND_MODE>( value ) );
\r
111 SlimDX::Direct2D::InterpolationMode BitmapBrush::InterpolationMode::get()
\r
113 return static_cast<SlimDX::Direct2D::InterpolationMode>( InternalPointer->GetInterpolationMode() );
\r
116 void BitmapBrush::InterpolationMode::set( SlimDX::Direct2D::InterpolationMode value )
\r
118 InternalPointer->SetInterpolationMode( static_cast<D2D1_BITMAP_INTERPOLATION_MODE>( value ) );
\r