source: trunk/Packages/DpiControls/Dpi.Graphics.pas

Last change on this file was 617, checked in by chronos, 5 weeks ago
  • Fixed: City screen rename right mouse click didn't work on Windows due to window title are. Change to behave the same way as on Linux.
  • Fixed: Allow full screen switching in editor and movie mode.
  • Modified: Precalculate scaling coefficients also for from native values conversions for faster speed.
File size: 36.6 KB
Line 
1unit Dpi.Graphics;
2
3interface
4
5uses
6 Classes, SysUtils, Math, Graphics, LCLType, GraphType, Types;
7
8const
9 clBlack = TColor($000000);
10 clWhite = TColor($ffffff);
11
12type
13 TColor = Graphics.TColor;
14 TPixelFormat = Graphics.TPixelFormat;
15 TFontStyle = Graphics.TFontStyle;
16
17 { TFont }
18
19 TFont = class(TPersistent)
20 private
21 FNativeFont: Graphics.TFont;
22 FNativeFontFree: Boolean;
23 FOnChange: TNotifyEvent;
24 FSize: Integer;
25 FHeight: Integer;
26 FPixelsPerInch: Integer;
27 FColor: TColor;
28 function GetCharSet: TFontCharSet;
29 function GetColor: TColor;
30 function GetHeight: Integer;
31 function GetName: string;
32 function GetPixelsPerInch: Integer;
33 function GetSize: Integer;
34 function GetStyle: TFontStyles;
35 function IsNameStored: Boolean;
36 procedure SetCharSet(AValue: TFontCharSet);
37 procedure SetColor(AValue: TColor);
38 procedure SetHeight(AValue: Integer);
39 procedure SetName(AValue: string);
40 procedure SetNativeFont(AValue: Graphics.TFont);
41 procedure SetPixelsPerInch(AValue: Integer);
42 procedure SetSize(AValue: Integer);
43 procedure DoChange;
44 procedure SetStyle(AValue: TFontStyles);
45 procedure UpdateFont;
46 protected
47 function GetNativeFont: Graphics.TFont; virtual;
48 public
49 procedure ScreenChanged;
50 property NativeFont: Graphics.TFont read FNativeFont write SetNativeFont;
51 constructor Create;
52 destructor Destroy; override;
53 procedure Assign(Source: TPersistent); override;
54 procedure GetTextSize(Text: string; var w, h: Integer);
55 function GetTextHeight(Text: string): Integer;
56 function GetTextWidth(Text: string): Integer;
57 published
58 property CharSet: TFontCharSet read GetCharSet write SetCharSet default DEFAULT_CHARSET;
59 property Color: TColor read GetColor write SetColor;
60 property Name: string read GetName write SetName stored IsNameStored;
61 property Style: TFontStyles read GetStyle write SetStyle default [];
62 property Size: Integer read GetSize write SetSize stored false;
63 property PixelsPerInch: Integer read GetPixelsPerInch write SetPixelsPerInch;
64 property Height: Integer read GetHeight write SetHeight default 0;
65 property OnChange: TNotifyEvent read FOnChange write FOnChange;
66 end;
67
68 { TPen }
69
70 TPen = class
71 FWidth: Integer;
72 FNativePen: Graphics.TPen;
73 FNativePenFree: Boolean;
74 private
75 function GetColor: TColor;
76 function GetStyle: TPenStyle;
77 function GetWidth: Integer;
78 procedure SetColor(AValue: TColor);
79 procedure SetNativePen(AValue: Graphics.TPen);
80 procedure SetStyle(AValue: TPenStyle);
81 procedure SetWidth(AValue: Integer);
82 public
83 constructor Create;
84 destructor Destroy; override;
85 function GetNativePen: Graphics.TPen;
86 procedure Assign(Source: TPen);
87 property NativePen: Graphics.TPen read FNativePen write SetNativePen;
88 published
89 property Color: TColor read GetColor write SetColor default clBlack;
90 property Style : TPenStyle read GetStyle write SetStyle default psSolid;
91 property Width: Integer read GetWidth write SetWidth default 1;
92 end;
93
94 TBrushStyle = Graphics.TBrushStyle;
95 TPenStyle = Graphics.TPenStyle;
96
97 { TBrush }
98
99 TBrush = class
100 private
101 FNativeBrush: Graphics.TBrush;
102 FNativeBrushFree: Boolean;
103 function GetColor: TColor;
104 function GetStyle: TBrushStyle;
105 procedure SetColor(AValue: TColor);
106 function GetNativeBrush: Graphics.TBrush;
107 procedure SetNativeBrush(AValue: Graphics.TBrush);
108 procedure SetStyle(AValue: TBrushStyle);
109 public
110 constructor Create;
111 destructor Destroy; override;
112 procedure Assign(Source: TBrush);
113 property NativeBrush: Graphics.TBrush read FNativeBrush write SetNativeBrush;
114 published
115 property Color: TColor read GetColor write SetColor default clWhite;
116 property Style: TBrushStyle read GetStyle write SetStyle default bsSolid;
117 end;
118
119 TGraphic = class;
120
121 { TCanvas }
122
123 TCanvas = class
124 private
125 FBrush: TBrush;
126 FBrushFree: Boolean;
127 FPen: TPen;
128 FPenFree: Boolean;
129 FFont: TFont;
130 FFontFree: Boolean;
131 FNativeCanvas: Graphics.TCanvas;
132 FNativeCanvasFree: Boolean;
133 function GetHandle: HDC;
134 function GetPixel(X, Y: Integer): TColor;
135 function GetTextStyle: TTextStyle;
136 procedure SetBrush(AValue: TBrush);
137 procedure SetFont(AValue: TFont);
138 procedure SetHandle(AValue: HDC);
139 procedure SetPen(AValue: TPen);
140 procedure SetPixel(X, Y: Integer; AValue: TColor);
141 procedure SetNativeCanvas(AValue: Graphics.TCanvas);
142 procedure SetTextStyle(AValue: TTextStyle);
143 protected
144 procedure DoLine(X1, Y1, X2, Y2: Integer); virtual;
145 procedure DoTextOut(X, Y: Integer; Text: string); virtual;
146 procedure DoRectangle(const Bounds: TRect); virtual;
147 procedure DoRectangleFill(const Bounds: TRect); virtual;
148 procedure DoPolygon(const Points: array of TPoint); virtual;
149 procedure CreateHandle; virtual;
150 procedure DoEllipse(const Bounds: TRect); virtual;
151 procedure DoMoveTo(X, Y: Integer); virtual;
152 procedure DoLineTo(X, Y: Integer); virtual;
153 procedure DoPolyline(const Points: array of TPoint); virtual;
154 procedure DoPolyBezier(Points: PPoint; NumPts: Integer;
155 Filled: Boolean = False; Continuous: Boolean = False); virtual;
156 procedure SetHeight(AValue: Integer); virtual;
157 procedure SetWidth(AValue: Integer); virtual;
158 function GetWidth: Integer; virtual;
159 function GetHeight: Integer; virtual;
160 function GetNativeCanvas: Graphics.TCanvas; virtual;
161 public
162 property NativeCanvas: Graphics.TCanvas read FNativeCanvas write SetNativeCanvas;
163 procedure RoundRect(const Rect: TRect; RX, RY: Integer); overload;
164 procedure RoundRect(X1, Y1, X2, Y2: Integer; RX,RY: Integer); overload; virtual;
165 procedure Polygon(const Points: array of TPoint; Winding: Boolean;
166 StartIndex: Integer = 0; NumPts: Integer = -1); overload;
167 procedure Polygon(Points: PPoint; NumPts: Integer; Winding: Boolean = False); virtual; overload;
168 procedure Polygon(const Points: array of TPoint); overload;
169 procedure PolyBezier(const Points: array of TPoint;
170 Filled: Boolean = False; Continuous: boolean = True); overload;
171 procedure PolyBezier(Points: PPoint; NumPts: Integer;
172 Filled: Boolean = False; Continuous: Boolean = True); virtual; overload;
173 procedure Polyline(const Points: array of TPoint); overload;
174 procedure Polyline(Points: PPoint; NumPts: Integer); virtual; overload;
175 procedure Ellipse(x1, y1, x2, y2: Integer); virtual; overload;
176 procedure Ellipse(const ARect: TRect); virtual; overload;
177// procedure StretchDraw(const DestRect: TRect; SrcGraphic: Graphics.TGraphic); virtual; overload;
178 procedure StretchDraw(const DestRect: TRect; SrcGraphic: TGraphic); virtual; overload;
179 procedure Pie(EllipseX1, EllipseY1, EllipseX2, EllipseY2,
180 StartX, StartY, EndX, EndY: Integer); virtual;
181 procedure FrameRect(Rect: TRect);
182 procedure Rectangle(X1, Y1, X2, Y2: Integer); overload;
183 procedure Rectangle(const ARect: TRect); overload;
184 function TextWidth(const Text: string): Integer;
185 function TextHeight(const Text: string): Integer;
186 function TextExtent(const Text: string): TSize; virtual;
187 procedure TextOut(X, Y: Integer; const Text: string); virtual;
188 procedure TextRect(ARect: TRect; X, Y: Integer; Text: string); overload;
189 procedure TextRect(ARect: TRect; X, Y: integer; const Text: string;
190 const Style: TTextStyle); overload;
191 procedure MoveTo(X, Y: Integer);
192 procedure LineTo(X, Y: Integer);
193 procedure Line(const p1, p2: TPoint);
194 procedure FillRect(const ARect: TRect); virtual; overload;
195 procedure FillRect(X1, Y1, X2, Y2: Integer); overload;
196 procedure Draw(X, Y: Integer; Source: TGraphic);
197 procedure CopyRect(Dest: TRect; SrcCanvas: TCanvas; Source: TRect);
198 constructor Create;
199 destructor Destroy; override;
200 property Handle: HDC read GetHandle write SetHandle;
201 property Pixels[X, Y: Integer]: TColor read GetPixel write SetPixel;
202 property Width: Integer read GetWidth;
203 property Height: Integer read GetHeight;
204 property TextStyle: TTextStyle read GetTextStyle write SetTextStyle;
205 published
206 property Brush: TBrush read FBrush write SetBrush;
207 property Pen: TPen read FPen write SetPen;
208 property Font: TFont read FFont write SetFont;
209 end;
210
211 { TGraphic }
212
213 TGraphic = class(TPersistent)
214 protected
215 FDpi: Integer;
216 function GetNativeGraphic: Graphics.TGraphic; virtual;
217 function GetWidth: Integer; virtual; abstract;
218 function GetHeight: Integer; virtual; abstract;
219 procedure SetWidth(Value: Integer); virtual; abstract;
220 procedure SetHeight(Value: Integer); virtual; abstract;
221 procedure ScreenChanged; virtual;
222 procedure SetDpi(AValue: Integer); virtual;
223 function GetDpi: Integer; virtual;
224 public
225 NativeGraphicClass: TGraphicClass;
226 constructor Create; virtual;
227 procedure LoadFromFile(const Filename: string); virtual;
228 procedure SaveToFile(const Filename: string); virtual;
229 property Width: Integer read GetWidth write SetWidth;
230 property Height: Integer read GetHeight write SetHeight;
231 property Dpi: Integer read GetDpi write SetDpi;
232 end;
233
234 { TRasterImage }
235
236 TRasterImage = class(TGraphic)
237 private
238 FCanvas: TCanvas;
239 function GetCanvas: TCanvas;
240 function GetRawImage: TRawImage;
241 protected
242 function GetHeight: Integer; override;
243 function GetWidth: Integer; override;
244 function GetPixelFormat: TPixelFormat; virtual; abstract;
245 procedure SetWidth(Value: Integer); override;
246 procedure SetHeight(Value: Integer); override;
247 procedure SetSize(AWidth, AHeight: Integer); virtual; abstract;
248 procedure SetPixelFormat(AValue: TPixelFormat); virtual; abstract;
249 function GetNativeGraphic: Graphics.TGraphic; override;
250 function GetNativeRasterImage: Graphics.TRasterImage; virtual;
251 procedure SetNativeRasterImage(CustomBitmap: Graphics.TRasterImage); virtual; abstract;
252 public
253 constructor Create; override;
254 destructor Destroy; override;
255 procedure BeginUpdate(ACanvasOnly: Boolean = False);
256 procedure EndUpdate(AStreamIsValid: Boolean = False);
257 property Canvas: TCanvas read GetCanvas;
258 property RawImage: TRawImage read GetRawImage;
259 property PixelFormat: TPixelFormat read GetPixelFormat write SetPixelFormat;
260 end;
261
262 { TCustomBitmap }
263
264 TCustomBitmap = class(TRasterImage)
265 private
266 FWidth: Integer;
267 FHeight: Integer;
268 protected
269 function GetHeight: Integer; override;
270 function GetWidth: Integer; override;
271 function GetPixelFormat: TPixelFormat; override;
272 procedure SetPixelFormat(AValue: TPixelFormat); override;
273 function GetNativeCustomBitmap: Graphics.TCustomBitmap; virtual;
274 function GetNativeRasterImage: Graphics.TRasterImage; override;
275 procedure SetNativeRasterImage(RasterImage: Graphics.TRasterImage); override;
276 procedure SetNativeCustomBitmap(CustomBitmap: Graphics.TCustomBitmap); virtual; abstract;
277 procedure ScreenChanged; override;
278 public
279 procedure Assign(Source: TPersistent); override;
280 procedure SetSize(AWidth, AHeight: Integer); override;
281 end;
282
283 { TBitmap }
284
285 TBitmap = class(TCustomBitmap)
286 private
287 function GetScanLine(Row: Integer): Pointer;
288 function GetTransparent: Boolean;
289 function GetTransparentColor: TColor;
290 procedure SetTransparent(AValue: Boolean);
291 procedure SetTransparentColor(AValue: TColor);
292 protected
293 function GetNativeBitmap: Graphics.TBitmap; virtual;
294 function GetNativeCustomBitmap: Graphics.TCustomBitmap; override;
295 procedure SetNativeBitmap(ANativeBitmap: Graphics.TBitmap); virtual;
296 procedure SetNativeCustomBitmap(CustomBitmap: Graphics.TCustomBitmap); override;
297 public
298 NativeBitmap: Graphics.TBitmap;
299 constructor Create; override;
300 destructor Destroy; override;
301 property ScanLine[Row: Integer]: Pointer read GetScanLine;
302 published
303 property TransparentColor: TColor read GetTransparentColor
304 write SetTransparentColor default clDefault;
305 property Transparent: Boolean read GetTransparent write SetTransparent default False;
306 end;
307
308 { TJpegImage }
309
310 TJpegImage = class(TCustomBitmap)
311 protected
312 function GetNativeCustomBitmap: Graphics.TCustomBitmap; override;
313 function GetNativeJpeg: Graphics.TJPEGImage; virtual;
314 procedure SetNativeCustomBitmap(CustomBitmap: Graphics.TCustomBitmap); override;
315 procedure SetNativeJpeg(Jpeg: Graphics.TJPEGImage); virtual;
316 public
317 NativeJpeg: Graphics.TJPEGImage;
318 constructor Create; override;
319 destructor Destroy; override;
320 end;
321
322 { TPortableNetworkGraphic }
323
324 TPortableNetworkGraphic = class(TCustomBitmap)
325 protected
326 function GetNativeCustomBitmap: Graphics.TCustomBitmap; override;
327 function GetNativePng: Graphics.TPortableNetworkGraphic; virtual;
328 procedure SetNativeCustomBitmap(CustomBitmap: Graphics.TCustomBitmap); override;
329 procedure SetNativePng(Png: Graphics.TPortableNetworkGraphic); virtual;
330 public
331 NativePng: Graphics.TPortableNetworkGraphic;
332 constructor Create; override;
333 destructor Destroy; override;
334 end;
335
336 { TPicture }
337
338 TPicture = class(TPersistent)
339 private
340 FBitmap: TBitmap;
341 procedure SetBitmap(AValue: TBitmap);
342 published
343 procedure LoadFromFile(FileName: string);
344 property Bitmap: TBitmap read FBitmap write SetBitmap;
345 end;
346
347 { TScreenInfo }
348
349 TScreenInfo = record
350 private
351 FDpi: Integer;
352 procedure SetDpi(AValue: Integer);
353 public
354 ToNative: Double;
355 FromNative: Double;
356 LookupToNative: array[-10000..10000] of Integer; // Should be sufficient for 8K screens
357 LookupFromNative: array[-10000..10000] of Integer; // Should be sufficient for 8K screens
358 property Dpi: Integer read FDpi write SetDpi;
359 end;
360
361var
362 ScreenInfo: TScreenInfo;
363
364
365implementation
366
367uses
368 Dpi.Common, NativePixelPointer;
369
370{ TCustomBitmap }
371
372function TCustomBitmap.GetHeight: Integer;
373begin
374 Result := FHeight;
375end;
376
377function TCustomBitmap.GetWidth: Integer;
378begin
379 Result := FWidth;
380end;
381
382function TCustomBitmap.GetPixelFormat: TPixelFormat;
383begin
384 Result := GetNativeCustomBitmap.PixelFormat;
385end;
386
387procedure TCustomBitmap.SetPixelFormat(AValue: TPixelFormat);
388begin
389 GetNativeCustomBitmap.PixelFormat := AValue;
390end;
391
392function TCustomBitmap.GetNativeCustomBitmap: Graphics.TCustomBitmap;
393begin
394 Result := nil;
395end;
396
397function TCustomBitmap.GetNativeRasterImage: Graphics.TRasterImage;
398begin
399 Result := GetNativeCustomBitmap;
400end;
401
402procedure TCustomBitmap.SetNativeRasterImage(RasterImage: Graphics.TRasterImage
403 );
404begin
405 SetNativeCustomBitmap(Graphics.TCustomBitmap(RasterImage));
406end;
407
408procedure TCustomBitmap.ScreenChanged;
409var
410 Bitmap: Graphics.TCustomBitmap;
411 NewWidth: Integer;
412 NewHeight: Integer;
413begin
414 NewWidth := ScaleToNative(Width);
415 NewHeight := ScaleToNative(Height);
416 if Assigned(GetNativeCustomBitmap) and ((NewWidth <> GetNativeCustomBitmap.Width) or
417 (NewHeight <> GetNativeCustomBitmap.Height)) then begin
418 // Rescale bitmap to new size
419 if NativeGraphicClass = Graphics.TBitmap then
420 Bitmap := Graphics.TBitmap.Create
421 else if NativeGraphicClass = Graphics.TPortableNetworkGraphic then
422 Bitmap := Graphics.TPortableNetworkGraphic.Create
423 else if NativeGraphicClass = Graphics.TJPEGImage then
424 Bitmap := Graphics.TJPEGImage.Create
425 else raise Exception.Create('Unsupported image class');
426 Bitmap.SetSize(NewWidth, NewHeight);
427 Bitmap.PixelFormat := GetNativeCustomBitmap.PixelFormat;
428 Bitmap.Canvas.StretchDraw(Bounds(0, 0, NewWidth, NewHeight), GetNativeCustomBitmap);
429 GetNativeCustomBitmap.Free;
430 SetNativeCustomBitmap(Bitmap);
431 Canvas.NativeCanvas := GetNativeCustomBitmap.Canvas;
432 end;
433end;
434
435procedure TCustomBitmap.Assign(Source: TPersistent);
436begin
437 if Source is TCustomBitmap then begin
438 GetNativeCustomBitmap.Assign(TCustomBitmap(Source).GetNativeCustomBitmap);
439 FWidth := TCustomBitmap(Source).FWidth;
440 FHeight := TCustomBitmap(Source).FHeight
441 end else inherited;
442end;
443
444procedure TCustomBitmap.SetSize(AWidth, AHeight: Integer);
445begin
446 FWidth := AWidth;
447 FHeight := AHeight;
448 GetNativeCustomBitmap.SetSize(ScaleToNative(AWidth), ScaleToNative(AHeight));
449end;
450
451{ TFont }
452
453procedure TFont.SetSize(AValue: Integer);
454begin
455 if FSize = AValue then Exit;
456 FSize := AValue;
457 FHeight := -MulDiv(FSize, FPixelsPerInch, 72);
458 UpdateFont;
459 DoChange;
460end;
461
462procedure TFont.DoChange;
463begin
464 if Assigned(FOnChange) then FOnChange(Self);
465end;
466
467procedure TFont.SetStyle(AValue: TFontStyles);
468begin
469 GetNativeFont.Style := AValue;
470end;
471
472procedure TFont.UpdateFont;
473begin
474 if Assigned(GetNativeFont) then begin
475 GetNativeFont.PixelsPerInch := FPixelsPerInch;
476 GetNativeFont.Size := FSize;
477 end;
478end;
479
480procedure TFont.ScreenChanged;
481begin
482 DoChange;
483end;
484
485function TFont.GetNativeFont: Graphics.TFont;
486begin
487 Result := NativeFont;
488end;
489
490procedure TFont.SetPixelsPerInch(AValue: Integer);
491begin
492 FPixelsPerInch := PixelsPerInch;
493 FHeight := -MulDiv(FSize, FPixelsPerInch, 72);
494 UpdateFont;
495end;
496
497function TFont.GetName: string;
498begin
499 Result := GetNativeFont.Name;
500end;
501
502function TFont.GetColor: TColor;
503begin
504 Result := FColor;
505end;
506
507function TFont.GetCharSet: TFontCharSet;
508begin
509 Result := GetNativeFont.CharSet;
510end;
511
512function TFont.GetHeight: Integer;
513begin
514 Result := GetNativeFont.Height;
515end;
516
517function TFont.GetPixelsPerInch: Integer;
518begin
519 Result := FPixelsPerInch;
520end;
521
522function TFont.GetSize: Integer;
523begin
524 Result := FSize;
525end;
526
527function TFont.GetStyle: TFontStyles;
528begin
529 Result := GetNativeFont.Style;
530end;
531
532function TFont.IsNameStored: Boolean;
533begin
534 Result := GetNativeFont.Name <> 'default';
535end;
536
537procedure TFont.SetCharSet(AValue: TFontCharSet);
538begin
539 GetNativeFont.CharSet := AValue;
540end;
541
542procedure TFont.SetColor(AValue: TColor);
543begin
544 if FColor = AValue then Exit;
545 FColor := AValue;
546 GetNativeFont.Color := AValue;
547end;
548
549procedure TFont.SetHeight(AValue: Integer);
550begin
551 FHeight := AValue;
552 FSize := MulDiv(-FHeight, 72, FPixelsPerInch);
553 UpdateFont;
554end;
555
556procedure TFont.SetName(AValue: string);
557begin
558 GetNativeFont.Name := AValue;
559end;
560
561procedure TFont.SetNativeFont(AValue: Graphics.TFont);
562begin
563 if FNativeFont = AValue then Exit;
564 if FNativeFontFree then FreeAndNil(FNativeFont);
565 FNativeFontFree := False;
566 FNativeFont := AValue;
567end;
568
569constructor TFont.Create;
570begin
571 FNativeFont := Graphics.TFont.Create;
572 FNativeFontFree := True;
573 FPixelsPerInch := ScreenInfo.Dpi;
574 Size := 8;
575 Color := clDefault;
576end;
577
578destructor TFont.Destroy;
579begin
580 if FNativeFontFree then
581 FreeAndNil(FNativeFont);
582 inherited;
583end;
584
585procedure TFont.Assign(Source: TPersistent);
586begin
587 if Source is TFont then begin
588 GetNativeFont.Assign((Source as TFont).GetNativeFont);
589 Size := (Source as TFont).Size;
590 Height := (Source as TFont).Height;
591 PixelsPerInch := (Source as TFont).PixelsPerInch;
592 FOnChange := (Source as TFont).FOnChange;
593 Color := (Source as TFont).Color;
594 end;
595end;
596
597procedure TFont.GetTextSize(Text: string; var w, h: Integer);
598begin
599 W := GetTextWidth(Text);
600 H := GetTextHeight(Text);
601end;
602
603function TFont.GetTextHeight(Text: string): Integer;
604begin
605 Result := ScaleFromNative(GetNativeFont.GetTextHeight(Text));
606end;
607
608function TFont.GetTextWidth(Text: string): Integer;
609begin
610 Result := ScaleFromNative(GetNativeFont.GetTextWidth(Text));
611end;
612
613{ TRasterImage }
614
615function TRasterImage.GetCanvas: TCanvas;
616begin
617 Result := FCanvas;
618end;
619
620function TRasterImage.GetRawImage: TRawImage;
621begin
622 Result := GetNativeRasterImage.RawImage;
623end;
624
625function TRasterImage.GetHeight: Integer;
626begin
627 Result := ScaleFromNative(GetNativeRasterImage.Height);
628end;
629
630function TRasterImage.GetWidth: Integer;
631begin
632 Result := ScaleFromNative(GetNativeRasterImage.Width);
633end;
634
635procedure TRasterImage.SetWidth(Value: Integer);
636begin
637 SetSize(Value, Height);
638end;
639
640procedure TRasterImage.SetHeight(Value: Integer);
641begin
642 SetSize(Width, Value);
643end;
644
645function TRasterImage.GetNativeRasterImage: Graphics.TRasterImage;
646begin
647 Result := nil;
648end;
649
650constructor TRasterImage.Create;
651begin
652 inherited;
653 FCanvas := TCanvas.Create;
654 FCanvas.NativeCanvas := GetNativeRasterImage.Canvas;
655end;
656
657destructor TRasterImage.Destroy;
658begin
659 FreeAndNil(FCanvas);
660 inherited;
661end;
662
663procedure TRasterImage.BeginUpdate(ACanvasOnly: Boolean);
664begin
665 GetNativeRasterImage.BeginUpdate(ACanvasOnly);
666end;
667
668procedure TRasterImage.EndUpdate(AStreamIsValid: Boolean);
669begin
670 GetNativeRasterImage.EndUpdate(AStreamIsValid);
671end;
672
673function TRasterImage.GetNativeGraphic: Graphics.TGraphic;
674begin
675 Result := GetNativeRasterImage;
676end;
677
678{ TGraphic }
679
680function TGraphic.GetNativeGraphic: Graphics.TGraphic;
681begin
682 Result := nil;
683end;
684
685procedure TGraphic.ScreenChanged;
686begin
687end;
688
689procedure TGraphic.SetDpi(AValue: Integer);
690begin
691 FDpi := AValue;
692 ScreenChanged;
693end;
694
695function TGraphic.GetDpi: Integer;
696begin
697 Result := FDpi;
698end;
699
700constructor TGraphic.Create;
701begin
702 Dpi := ScreenInfo.Dpi;
703end;
704
705procedure StretchDrawBitmap(Src: Graphics.TRasterImage; Dst: Graphics.TCustomBitmap);
706var
707 SrcPtr: TPixelPointer;
708 DstPtr: TPixelPointer;
709 XX, YY: Integer;
710 DstPixelX, DstPixelY: Integer;
711 DstPixelWidth, DstPixelHeight: Integer;
712begin
713 Dst.BeginUpdate;
714 SrcPtr := TPixelPointer.Create(Src, 0, 0);
715 DstPtr := TPixelPointer.Create(Dst, 0, 0);
716 for YY := 0 to Src.Height - 1 do begin
717 DstPixelHeight := ScaleToNative(YY + 1) - ScaleToNative(YY);
718 for DstPixelY := 0 to DstPixelHeight - 1 do begin
719 for XX := 0 to Src.Width - 1 do begin
720 DstPixelWidth := ScaleToNative(XX + 1) - ScaleToNative(XX);
721 for DstPixelX := 0 to DstPixelWidth - 1 do begin
722 DstPtr.PixelRGB := SrcPtr.PixelRGB;
723 DstPtr.NextPixel;
724 end;
725 SrcPtr.NextPixel;
726 end;
727 DstPtr.NextLine;
728 SrcPtr.SetX(0);
729 end;
730 SrcPtr.NextLine;
731 end;
732 Dst.EndUpdate;
733end;
734
735procedure TGraphic.LoadFromFile(const Filename: string);
736var
737 Bitmap: Graphics.TGraphic;
738begin
739 Bitmap := NativeGraphicClass.Create;
740 try
741 Bitmap.LoadFromFile(FileName);
742 if Self is TRasterImage then begin
743 TRasterImage(Self).SetSize(Bitmap.Width, Bitmap.Height);
744 end else begin
745 Width := Bitmap.Width;
746 Height := Bitmap.Height;
747 end;
748 if Self is TCustomBitmap then begin
749 StretchDrawBitmap(Graphics.TRasterImage(Bitmap),
750 Graphics.TCustomBitmap(GetNativeGraphic));
751 //Graphics.TBitmap(GetNativeGraphic).Canvas.StretchDraw(Bounds(0, 0,
752 //Graphics.TBitmap(GetNativeGraphic).Width, TBitmap(GetNativeGraphic).Height), Bitmap);
753 end else raise Exception.Create('Unsupported class ' + Self.ClassName);
754 finally
755 FreeAndNil(Bitmap);
756 end;
757end;
758
759procedure TGraphic.SaveToFile(const Filename: string);
760var
761 Bitmap: Graphics.TGraphic;
762begin
763 Bitmap := NativeGraphicClass.Create;
764 try
765 Bitmap.Width := Width;
766 Bitmap.Height := Height;
767 if Self is TBitmap then begin
768 if Bitmap is Graphics.TRasterImage then
769 (Bitmap as Graphics.TRasterImage).Canvas.StretchDraw(Bounds(0, 0, Bitmap.Width,
770 Bitmap.Height), Graphics.TBitmap(GetNativeGraphic))
771 else raise Exception.Create('Expected TRasterImage but got ' + Bitmap.ClassName);
772 end else raise Exception.Create('Unsupported class ' + Self.ClassName);
773 Bitmap.SaveToFile(FileName);
774 finally
775 FreeAndNil(Bitmap);
776 end;
777end;
778
779{ TBitmap }
780
781function TBitmap.GetScanLine(Row: Integer): Pointer;
782begin
783 Result := GetNativeBitmap.ScanLine[Row];
784end;
785
786function TBitmap.GetTransparent: Boolean;
787begin
788 Result := GetNativeBitmap.Transparent;
789end;
790
791function TBitmap.GetTransparentColor: TColor;
792begin
793 Result := GetNativeBitmap.TransparentColor;
794end;
795
796procedure TBitmap.SetTransparent(AValue: Boolean);
797begin
798 GetNativeBitmap.Transparent := AValue;
799end;
800
801procedure TBitmap.SetTransparentColor(AValue: TColor);
802begin
803 GetNativeBitmap.TransparentColor := AValue;
804end;
805
806function TBitmap.GetNativeBitmap: Graphics.TBitmap;
807begin
808 Result := NativeBitmap;
809end;
810
811function TBitmap.GetNativeCustomBitmap: Graphics.TCustomBitmap;
812begin
813 Result := GetNativeBitmap;
814end;
815
816procedure TBitmap.SetNativeBitmap(ANativeBitmap: Graphics.TBitmap);
817begin
818 NativeBitmap := ANativeBitmap;
819end;
820
821procedure TBitmap.SetNativeCustomBitmap(CustomBitmap: Graphics.TCustomBitmap);
822begin
823 SetNativeBitmap(Graphics.TBitmap(CustomBitmap));
824end;
825
826constructor TBitmap.Create;
827begin
828 NativeGraphicClass := Graphics.TBitmap;
829 NativeBitmap := Graphics.TBitmap.Create;
830 inherited;
831end;
832
833destructor TBitmap.Destroy;
834begin
835 FreeAndNil(FCanvas);
836 FreeAndNil(NativeBitmap);
837 inherited;
838end;
839
840{ TPen }
841
842function TPen.GetColor: TColor;
843begin
844 Result := GetNativePen.Color;
845end;
846
847function TPen.GetStyle: TPenStyle;
848begin
849 Result := GetNativePen.Style;
850end;
851
852function TPen.GetWidth: Integer;
853begin
854 Result := FWidth;
855end;
856
857procedure TPen.SetColor(AValue: TColor);
858begin
859 GetNativePen.Color := AValue;
860end;
861
862procedure TPen.SetNativePen(AValue: Graphics.TPen);
863begin
864 if FNativePen = AValue then Exit;
865 if FNativePenFree then FreeAndNil(FNativePen);
866 FNativePenFree := False;
867 FNativePen := AValue;
868 SetWidth(FWidth);
869end;
870
871procedure TPen.SetStyle(AValue: TPenStyle);
872begin
873 GetNativePen.Style := AValue;
874end;
875
876procedure TPen.SetWidth(AValue: Integer);
877begin
878 GetNativePen.Width := ScaleToNative(AValue);
879 FWidth := AValue;
880end;
881
882constructor TPen.Create;
883begin
884 FNativePen := Graphics.TPen.Create;
885 FNativePenFree := True;
886 FWidth := 1;
887end;
888
889destructor TPen.Destroy;
890begin
891 if FNativePenFree then
892 FreeAndNil(FNativePen);
893 inherited;
894end;
895
896function TPen.GetNativePen: Graphics.TPen;
897begin
898 Result := FNativePen;
899end;
900
901procedure TPen.Assign(Source: TPen);
902begin
903 FWidth := Source.FWidth;
904 GetNativePen.Assign(Source.GetNativePen);
905end;
906
907{ TBrush }
908
909function TBrush.GetColor: TColor;
910begin
911 Result := GetNativeBrush.Color;
912end;
913
914function TBrush.GetStyle: TBrushStyle;
915begin
916 Result := GetNativeBrush.Style;
917end;
918
919procedure TBrush.SetColor(AValue: TColor);
920begin
921 GetNativeBrush.Color := AValue;
922end;
923
924function TBrush.GetNativeBrush: Graphics.TBrush;
925begin
926 Result := FNativeBrush;
927end;
928
929procedure TBrush.SetNativeBrush(AValue: Graphics.TBrush);
930begin
931 if FNativeBrush = AValue then Exit;
932 if FNativeBrushFree then FreeAndNil(FNativeBrush);
933 FNativeBrushFree := False;
934 FNativeBrush := AValue;
935end;
936
937procedure TBrush.SetStyle(AValue: TBrushStyle);
938begin
939 GetNativeBrush.Style := AValue;
940end;
941
942constructor TBrush.Create;
943begin
944 FNativeBrush := Graphics.TBrush.Create;
945 FNativeBrushFree := True;
946end;
947
948destructor TBrush.Destroy;
949begin
950 if FNativeBrushFree then FreeAndNil(FNativeBrush);
951 inherited;
952end;
953
954procedure TBrush.Assign(Source: TBrush);
955begin
956 GetNativeBrush.Assign(Source.GetNativeBrush);
957end;
958
959{ TCanvas }
960
961function TCanvas.GetHandle: HDC;
962begin
963 Result := GetNativeCanvas.Handle;
964end;
965
966function TCanvas.GetHeight: Integer;
967begin
968 Result := ScaleFromNative(GetNativeCanvas.Height);
969end;
970
971function TCanvas.GetPixel(X, Y: Integer): TColor;
972begin
973 Result := GetNativeCanvas.Pixels[ScaleToNative(X), ScaleToNative(Y)];
974end;
975
976function TCanvas.GetTextStyle: TTextStyle;
977begin
978 Result := GetNativeCanvas.TextStyle;
979end;
980
981function TCanvas.GetWidth: Integer;
982begin
983 Result := ScaleFromNative(GetNativeCanvas.Width);
984end;
985
986procedure TCanvas.SetBrush(AValue: TBrush);
987begin
988 if FBrush = AValue then Exit;
989 if FBrushFree then FreeAndNil(FBrush);
990 FBrushFree := False;
991 FBrush := AValue;
992end;
993
994procedure TCanvas.SetFont(AValue: TFont);
995begin
996 if FFont = AValue then Exit;
997 if FFontFree then FreeAndNil(FFont);
998 FFontFree := False;
999 FFont := AValue;
1000end;
1001
1002procedure TCanvas.SetHandle(AValue: HDC);
1003begin
1004 GetNativeCanvas.Handle := AValue;
1005end;
1006
1007procedure TCanvas.SetHeight(AValue: Integer);
1008begin
1009 GetNativeCanvas.Height;
1010end;
1011
1012procedure TCanvas.SetWidth(AValue: Integer);
1013begin
1014
1015end;
1016
1017procedure TCanvas.SetPen(AValue: TPen);
1018begin
1019 if FPen = AValue then Exit;
1020 if FPenFree then FreeAndNil(FPen);
1021 FPenFree := False;
1022 FPen := AValue;
1023end;
1024
1025procedure TCanvas.SetPixel(X, Y: Integer; AValue: TColor);
1026var
1027 BrushStyle: TBrushStyle;
1028 BrushColor: TColor;
1029begin
1030 { BrushStyle := GetNativeCanvas.Brush.Style;
1031 BrushColor := GetNativeCanvas.Brush.Color;
1032 GetNativeCanvas.Brush.Color := AValue;
1033 GetNativeCanvas.Brush.Style := bsClear;
1034 GetNativeCanvas.FillRect(ScaleToNative(X), ScaleToNative(Y), ScaleToNative(X + 1) - 1, ScaleToNative(Y + 1) - 1);
1035 GetNativeCanvas.Brush.Style := BrushStyle;
1036 GetNativeCanvas.Brush.Color := BrushColor;
1037 }
1038 GetNativeCanvas.Pixels[ScaleToNative(X), ScaleToNative(Y)] := AValue;
1039end;
1040
1041procedure TCanvas.SetNativeCanvas(AValue: Graphics.TCanvas);
1042begin
1043 if FNativeCanvas = AValue then Exit;
1044 if FNativeCanvasFree then FreeAndNil(FNativeCanvas);
1045 FNativeCanvasFree := False;
1046 FNativeCanvas := AValue;
1047 if Assigned(FNativeCanvas) then begin
1048 FFont.NativeFont := FNativeCanvas.Font;
1049 FBrush.NativeBrush := FNativeCanvas.Brush;
1050 FPen.NativePen := FNativeCanvas.Pen;
1051 end;
1052end;
1053
1054procedure TCanvas.SetTextStyle(AValue: TTextStyle);
1055begin
1056 GetNativeCanvas.TextStyle := AValue;
1057end;
1058
1059procedure TCanvas.DoLine(X1, Y1, X2, Y2: Integer);
1060begin
1061 raise ENotImplemented.Create(SNotImplemented);
1062end;
1063
1064procedure TCanvas.DoTextOut(X, Y: Integer; Text: string);
1065begin
1066 raise ENotImplemented.Create(SNotImplemented);
1067end;
1068
1069procedure TCanvas.DoRectangle(const Bounds: TRect);
1070begin
1071 raise ENotImplemented.Create(SNotImplemented);
1072end;
1073
1074procedure TCanvas.DoRectangleFill(const Bounds: TRect);
1075begin
1076 raise ENotImplemented.Create(SNotImplemented);
1077end;
1078
1079procedure TCanvas.DoPolygon(const Points: array of TPoint);
1080begin
1081 raise ENotImplemented.Create(SNotImplemented);
1082end;
1083
1084procedure TCanvas.CreateHandle;
1085begin
1086 raise ENotImplemented.Create(SNotImplemented);
1087end;
1088
1089procedure TCanvas.DoEllipse(const Bounds: TRect);
1090begin
1091 raise ENotImplemented.Create(SNotImplemented);
1092end;
1093
1094procedure TCanvas.DoMoveTo(X, Y: Integer);
1095begin
1096 raise ENotImplemented.Create(SNotImplemented);
1097end;
1098
1099procedure TCanvas.DoLineTo(X, Y: Integer);
1100begin
1101 raise ENotImplemented.Create(SNotImplemented);
1102end;
1103
1104procedure TCanvas.DoPolyline(const Points: array of TPoint);
1105begin
1106 raise ENotImplemented.Create(SNotImplemented);
1107end;
1108
1109procedure TCanvas.DoPolyBezier(Points: PPoint; NumPts: Integer;
1110 Filled: Boolean; Continuous: Boolean);
1111begin
1112 raise ENotImplemented.Create(SNotImplemented);
1113end;
1114
1115function TCanvas.GetNativeCanvas: Graphics.TCanvas;
1116begin
1117 Result := NativeCanvas;
1118end;
1119
1120procedure TCanvas.RoundRect(const Rect: TRect; RX, RY: Integer);
1121begin
1122 GetNativeCanvas.RoundRect(Rect, RX, RY);
1123end;
1124
1125procedure TCanvas.RoundRect(X1, Y1, X2, Y2: Integer; RX, RY: Integer);
1126begin
1127 GetNativeCanvas.RoundRect(X1, Y1, X2, Y2, RX, RY);
1128end;
1129
1130procedure TCanvas.Polygon(const Points: array of TPoint; Winding: Boolean;
1131 StartIndex: Integer; NumPts: Integer);
1132begin
1133 GetNativeCanvas.Polygon(Points, Winding, StartIndex, NumPts);
1134end;
1135
1136procedure TCanvas.Polygon(Points: PPoint; NumPts: Integer; Winding: Boolean);
1137begin
1138 GetNativeCanvas.Polygon(Points, NumPts, Winding);
1139end;
1140
1141procedure TCanvas.Polygon(const Points: array of TPoint);
1142begin
1143 GetNativeCanvas.Polygon(Points);
1144end;
1145
1146procedure TCanvas.PolyBezier(const Points: array of TPoint; Filled: Boolean;
1147 Continuous: boolean);
1148begin
1149 GetNativeCanvas.Polyline(Points);
1150end;
1151
1152procedure TCanvas.PolyBezier(Points: PPoint; NumPts: Integer;
1153 Filled: Boolean; Continuous: Boolean);
1154begin
1155 GetNativeCanvas.PolyBezier(Points, NumPts, Filled, Continuous);
1156end;
1157
1158procedure TCanvas.Polyline(const Points: array of TPoint);
1159begin
1160 GetNativeCanvas.Polyline(Points);
1161end;
1162
1163procedure TCanvas.Polyline(Points: PPoint; NumPts: Integer);
1164begin
1165 GetNativeCanvas.Polyline(Points, NumPts);
1166end;
1167
1168procedure TCanvas.Ellipse(x1, y1, x2, y2: Integer);
1169begin
1170 GetNativeCanvas.Ellipse(X1, Y1, X2, Y2);
1171end;
1172
1173procedure TCanvas.Ellipse(const ARect: TRect);
1174begin
1175 Ellipse(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
1176end;
1177
1178{procedure TCanvas.StretchDraw(const DestRect: TRect; SrcGraphic: Graphics.TGraphic);
1179begin
1180 GetNativeCanvas.StretchDraw(DestRect, SrcGraphic);
1181end;
1182}
1183procedure TCanvas.Pie(EllipseX1, EllipseY1, EllipseX2, EllipseY2, StartX,
1184 StartY, EndX, EndY: Integer);
1185begin
1186 GetNativeCanvas.Pie(EllipseX1, EllipseY1, EllipseX2, EllipseY2, StartX, StartY,
1187 EndX, EndY);
1188end;
1189
1190procedure TCanvas.StretchDraw(const DestRect: TRect; SrcGraphic: TGraphic
1191 );
1192begin
1193 GetNativeCanvas.StretchDraw(ScaleRectToNative(DestRect), SrcGraphic.GetNativeGraphic);
1194end;
1195
1196procedure TCanvas.FrameRect(Rect: TRect);
1197begin
1198 GetNativeCanvas.FrameRect(ScaleRectToNative(Rect));
1199end;
1200
1201procedure TCanvas.Rectangle(X1, Y1, X2, Y2: Integer);
1202begin
1203 GetNativeCanvas.Rectangle(ScaleToNative(X1), ScaleToNative(Y1), ScaleToNative(X2), ScaleToNative(Y2));
1204end;
1205
1206procedure TCanvas.Rectangle(const ARect: TRect);
1207begin
1208 Rectangle(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
1209end;
1210
1211function TCanvas.TextWidth(const Text: string): Integer;
1212begin
1213 Result := ScaleFromNative(GetNativeCanvas.TextWidth(Text));
1214end;
1215
1216function TCanvas.TextHeight(const Text: string): Integer;
1217begin
1218 Result := ScaleFromNative(GetNativeCanvas.TextHeight(Text));
1219end;
1220
1221function TCanvas.TextExtent(const Text: string): TSize;
1222begin
1223 Result := ScaleSizeFromNative(GetNativeCanvas.TextExtent(Text));
1224end;
1225
1226procedure TCanvas.TextOut(X, Y: Integer; const Text: string);
1227begin
1228 GetNativeCanvas.TextOut(ScaleToNative(X), ScaleToNative(Y), Text);
1229end;
1230
1231procedure TCanvas.TextRect(ARect: TRect; X, Y: Integer; Text: string);
1232begin
1233 GetNativeCanvas.TextRect(ScaleRectToNative(ARect), ScaleToNative(X),
1234 ScaleToNative(Y), Text);
1235end;
1236
1237procedure TCanvas.TextRect(ARect: TRect; X, Y: integer; const Text: string;
1238 const Style: TTextStyle);
1239begin
1240 GetNativeCanvas.TextRect(ScaleRectToNative(ARect), ScaleToNative(X),
1241 ScaleToNative(Y), Text, TextStyle);
1242end;
1243
1244procedure TCanvas.MoveTo(X, Y: Integer);
1245begin
1246 GetNativeCanvas.MoveTo(ScaleToNative(X), ScaleToNative(Y));
1247end;
1248
1249procedure TCanvas.LineTo(X, Y: Integer);
1250begin
1251 GetNativeCanvas.LineTo(ScaleToNative(X), ScaleToNative(Y));
1252end;
1253
1254procedure TCanvas.Line(const p1, p2: TPoint);
1255begin
1256 GetNativeCanvas.Line(P1, P2);
1257end;
1258
1259procedure TCanvas.FillRect(const ARect: TRect);
1260begin
1261 GetNativeCanvas.FillRect(ScaleRectToNative(ARect));
1262end;
1263
1264procedure TCanvas.FillRect(X1, Y1, X2, Y2: Integer);
1265begin
1266 GetNativeCanvas.FillRect(ScaleToNative(X1), ScaleToNative(Y1), ScaleToNative(X2), ScaleToNative(Y2));
1267end;
1268
1269procedure TCanvas.Draw(X, Y: Integer; Source: TGraphic);
1270begin
1271 GetNativeCanvas.Draw(ScaleToNative(X), ScaleToNative(Y), Source.GetNativeGraphic);
1272end;
1273
1274procedure TCanvas.CopyRect(Dest: TRect; SrcCanvas: TCanvas;
1275 Source: TRect);
1276begin
1277 GetNativeCanvas.CopyRect(Dest, SrcCanvas.NativeCanvas, ScaleRectToNative(Source));
1278end;
1279
1280constructor TCanvas.Create;
1281begin
1282 FNativeCanvas := nil;
1283 FFont := TFont.Create;
1284 FFontFree := True;
1285 FPen := TPen.Create;
1286 FPenFree := True;
1287 FBrush := TBrush.Create;
1288 FBrushFree := True;
1289end;
1290
1291destructor TCanvas.Destroy;
1292begin
1293 if FFontFree then FreeAndNil(FFont);
1294 if FBrushFree then FreeAndNil(FBrush);
1295 if FPenFree then FreeAndNil(FPen);
1296 if FNativeCanvasFree then FreeAndNil(FNativeCanvasFree);
1297 inherited;
1298end;
1299
1300{ TJpegImage }
1301
1302function TJpegImage.GetNativeCustomBitmap: Graphics.TCustomBitmap;
1303begin
1304 Result := GetNativeJpeg;
1305end;
1306
1307function TJpegImage.GetNativeJpeg: Graphics.TJPEGImage;
1308begin
1309 Result := NativeJpeg;
1310end;
1311
1312procedure TJpegImage.SetNativeCustomBitmap(CustomBitmap: Graphics.TCustomBitmap
1313 );
1314begin
1315 SetNativeJpeg(Graphics.TJpegImage(CustomBitmap));
1316end;
1317
1318procedure TJpegImage.SetNativeJpeg(Jpeg: Graphics.TJPEGImage);
1319begin
1320 NativeJpeg := Jpeg;
1321end;
1322
1323constructor TJpegImage.Create;
1324begin
1325 NativeJpeg := Graphics.TJPEGImage.Create;
1326 NativeGraphicClass := Graphics.TJPEGImage;
1327 inherited;
1328end;
1329
1330destructor TJpegImage.Destroy;
1331begin
1332 FreeAndNil(NativeJpeg);
1333 inherited;
1334end;
1335
1336{ TPicture }
1337
1338procedure TPicture.SetBitmap(AValue: TBitmap);
1339begin
1340 if FBitmap = AValue then Exit;
1341 FBitmap := AValue;
1342end;
1343
1344procedure TPicture.LoadFromFile(FileName: string);
1345begin
1346end;
1347
1348{ TScreenInfo }
1349
1350procedure TScreenInfo.SetDpi(AValue: Integer);
1351var
1352 I: Integer;
1353begin
1354 if FDpi = AValue then Exit;
1355 FDpi := AValue;
1356
1357 // Precalculate scaling coefficients
1358 ToNative := ScreenInfo.Dpi / 96;
1359 for I := Low(LookupToNative) to High(LookupToNative) do
1360 LookupToNative[I] := Ceil(I * ToNative);
1361 FromNative := 96 / ScreenInfo.Dpi;
1362 for I := Low(LookupFromNative) to High(LookupFromNative) do
1363 LookupFromNative[I] := Floor(I * FromNative);
1364end;
1365
1366{ TPortableNetworkGraphic }
1367
1368function TPortableNetworkGraphic.GetNativeCustomBitmap: Graphics.TCustomBitmap;
1369begin
1370 Result := GetNativePng;
1371end;
1372
1373function TPortableNetworkGraphic.GetNativePng: Graphics.TPortableNetworkGraphic;
1374begin
1375 Result := NativePng;
1376end;
1377
1378procedure TPortableNetworkGraphic.SetNativeCustomBitmap(
1379 CustomBitmap: Graphics.TCustomBitmap);
1380begin
1381 SetNativePng(Graphics.TPortableNetworkGraphic(CustomBitmap));
1382end;
1383
1384procedure TPortableNetworkGraphic.SetNativePng(
1385 Png: Graphics.TPortableNetworkGraphic);
1386begin
1387 NativePng := Png;
1388end;
1389
1390constructor TPortableNetworkGraphic.Create;
1391begin
1392 NativePng := Graphics.TPortableNetworkGraphic.Create;
1393 NativeGraphicClass := Graphics.TPortableNetworkGraphic;
1394 inherited;
1395end;
1396
1397destructor TPortableNetworkGraphic.Destroy;
1398begin
1399 Canvas.NativeCanvas := nil;
1400 FreeAndNil(NativePng);
1401 inherited;
1402end;
1403
1404end.
1405
Note: See TracBrowser for help on using the repository browser.