Changeset 317 for GraphicTest/BGRABitmap/bgrabitmap.pas
- Timestamp:
- Feb 1, 2012, 3:02:33 PM (13 years ago)
- Location:
- GraphicTest/BGRABitmap
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/BGRABitmap
-
Property svn:ignore
set to
lib
-
Property svn:ignore
set to
-
GraphicTest/BGRABitmap/bgrabitmap.pas
r210 r317 41 41 interface 42 42 43 { Compiler directives are used to include the best version according 44 to the platform } 45 43 46 uses 44 47 Classes, SysUtils, … … 81 84 {$ENDIF} 82 85 83 86 // draw a bitmap from pure data 84 87 procedure BGRABitmapDraw(ACanvas: TCanvas; Rect: TRect; AData: Pointer; 85 88 VerticalFlip: boolean; AWidth, AHeight: integer; Opaque: boolean); 86 procedure BGRAReplace(var Source: TBGRABitmap; Temp: TObject); 89 90 { Replace the content of the variable Destination with the variable 91 Temp and frees previous object contained in Destination. 92 93 This function is useful as a shortcut for : 94 95 var 96 temp: TBGRABitmap; 97 begin 98 ... 99 temp := someBmp.Filter... as TBGRABitmap; 100 someBmp.Free; 101 someBmp := temp; 102 end; 103 104 which becomes : 105 106 begin 107 ... 108 BGRAReplace(temp, someBmp.Filter... ); 109 end; 110 } 111 procedure BGRAReplace(var Destination: TBGRABitmap; Temp: TObject); 87 112 88 113 implementation 89 114 90 uses GraphType, BGRA AnimatedGif;115 uses GraphType, BGRABitmapTypes; 91 116 92 117 var 93 bmp: TBGRABitmap;118 tempBmp: TBGRABitmap; 94 119 95 120 procedure BGRABitmapDraw(ACanvas: TCanvas; Rect: TRect; AData: Pointer; … … 98 123 LineOrder: TRawImageLineOrder; 99 124 begin 125 if tempBmp = nil then 126 tempBmp := TBGRABitmap.Create; 100 127 if VerticalFlip then 101 128 LineOrder := riloBottomToTop … … 103 130 LineOrder := riloTopToBottom; 104 131 if Opaque then 105 bmp.DataDrawOpaque(ACanvas, Rect, AData, LineOrder, AWidth, AHeight)132 tempBmp.DataDrawOpaque(ACanvas, Rect, AData, LineOrder, AWidth, AHeight) 106 133 else 107 bmp.DataDrawTransparent(ACanvas, Rect, AData, LineOrder, AWidth, AHeight);134 tempBmp.DataDrawTransparent(ACanvas, Rect, AData, LineOrder, AWidth, AHeight); 108 135 end; 109 136 110 procedure BGRAReplace(var Source: TBGRABitmap; Temp: TObject);137 procedure BGRAReplace(var Destination: TBGRABitmap; Temp: TObject); 111 138 begin 112 Source.Free;113 Source:= Temp as TBGRABitmap;139 Destination.Free; 140 Destination := Temp as TBGRABitmap; 114 141 end; 115 142 116 143 initialization 117 144 118 bmp := TBGRABitmap.Create(0, 0); 145 //this variable is assigned to access appropriate functions 146 //depending on the platform 147 BGRABitmapFactory := TBGRABitmap; 119 148 120 149 finalization 121 150 122 bmp.Free;151 tempBmp.Free; 123 152 124 153 end.
Note:
See TracChangeset
for help on using the changeset viewer.