mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-27 19:13:52 +02:00
cocoa: Adds a initial code for rendering a TCocoaBitmap into a TCocoaContext
git-svn-id: trunk@33685 -
This commit is contained in:
parent
f67944b557
commit
6c62624064
@ -8,8 +8,8 @@ interface
|
||||
{$modeswitch objectivec1}
|
||||
|
||||
uses
|
||||
MacOSAll, // for CGContextRef
|
||||
LCLtype,
|
||||
SysUtils, MacOSAll, // for CGContextRef
|
||||
LCLtype, LCLProc,
|
||||
CocoaAll, CocoaUtils,
|
||||
Classes, Types;
|
||||
|
||||
@ -203,6 +203,7 @@ type
|
||||
procedure TextOut(X,Y: Integer; UTF8Chars: PChar; Count: Integer; CharsDelta: PInteger);
|
||||
function GetTextExtentPoint(AStr: PChar; ACount: Integer; var Size: TSize): Boolean;
|
||||
function GetTextMetrics(var TM: TTextMetric): Boolean;
|
||||
procedure DrawBitmap(X,Y: Integer; ABitmap: TCocoaBitmap);
|
||||
procedure SetOrigin(X,Y: Integer);
|
||||
procedure GetOrigin(var X,Y: Integer);
|
||||
function CGContext: CGContextRef; virtual;
|
||||
@ -280,6 +281,11 @@ var
|
||||
HasAlpha: Boolean;
|
||||
BitmapFormat: NSBitmapFormat;
|
||||
begin
|
||||
{$ifdef VerboseBitmaps}
|
||||
DebugLn(Format('[TCocoaBitmap.Create] AWidth=%d AHeight=%d ADepth=%d ABitsPerPixel=%d'
|
||||
+ ' AAlignment=%d AType=%d AData=? ACopyData=%d',
|
||||
[AWidth, AHeight, ADepth, ABitsPerPixel, Integer(AAlignment), Integer(AType), Integer(ACopyData)]));
|
||||
{$endif}
|
||||
SetInfo(AWidth, AHeight, ADepth, ABitsPerPixel, AAlignment, AType);
|
||||
|
||||
// Copy the image data, if necessary
|
||||
@ -303,6 +309,10 @@ begin
|
||||
if AType = cbtARGB then
|
||||
BitmapFormat := BitmapFormat or NSAlphaFirstBitmapFormat;
|
||||
|
||||
{$ifdef VerboseBitmaps}
|
||||
DebugLn(Format('[TCocoaBitmap.Create] NSBitmapImageRep.alloc HasAlpha=%d',
|
||||
[Integer(HasAlpha)]));
|
||||
{$endif}
|
||||
// Create the associated NSImageRep
|
||||
imagerep := NSBitmapImageRep(NSBitmapImageRep.alloc.initWithBitmapDataPlanes_pixelsWide_pixelsHigh__colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel(
|
||||
@FData, // planes, BitmapDataPlanes
|
||||
@ -769,6 +779,14 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TCocoaContext.DrawBitmap(X,Y:Integer; ABitmap: TCocoaBitmap);
|
||||
begin
|
||||
NSGraphicsContext.saveGraphicsState();
|
||||
NSGraphicsContext.setCurrentContext(ctx);
|
||||
ABitmap.imagerep.drawAtPoint(NSMakePoint(X, Y));
|
||||
NSGraphicsContext.restoreGraphicsState();
|
||||
end;
|
||||
|
||||
procedure TCocoaContext.SetOrigin(X,Y:Integer);
|
||||
var
|
||||
cg : CGContextRef;
|
||||
|
Loading…
Reference in New Issue
Block a user