File: vtgraphicsi.inc

package info (click to toggle)
lazarus 2.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 214,460 kB
  • sloc: pascal: 1,862,622; xml: 265,709; cpp: 56,595; sh: 3,008; java: 609; makefile: 535; perl: 297; sql: 222; ansic: 137
file content (59 lines) | stat: -rw-r--r-- 1,594 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
uses
  gtk2def, gdk2, GTK2Proc, Cairo, LCLVersion;

{$MACRO ON}

{$if lcl_fullversion > 1000000}
{$define TGtk2DeviceContext:=TGtkDeviceContext}
{$endif}

function gdk_cairo_create(drawable: PGdkDrawable): Pcairo_t cdecl external gdklib;

procedure AlphaBlend(Source, Destination: HDC; const R: TRect; const Target: TPoint; Mode: TBlendMode; ConstantAlpha, Bias: Integer);

  function GetContext(GtkDC: TGtk2DeviceContext): Pcairo_t;
  begin
    Result := nil;
    if (GtkDC <> nil) and (GtkDC.Drawable <> nil) then
        Result := gdk_cairo_create(GtkDC.Drawable);
  end;

var
  SrcDC: TGtk2DeviceContext absolute Source;
  DestDC: TGtk2DeviceContext absolute Destination;
  SrcContext, DestContext: Pcairo_t;
begin
  case Mode of
    bmConstantAlpha:;
    bmPerPixelAlpha:;
    bmMasterAlpha:;
    bmConstantAlphaAndColor:
      begin
        DestContext := GetContext(DestDC);
        if DestContext <> nil then
        begin
          cairo_set_source_rgba(DestContext,
            (Bias and $000000FF) / 255,
            ((Bias shr 8) and $000000FF) / 255,
            ((Bias shr 16) and $000000FF) / 255,
            ConstantAlpha / 255
            );
          cairo_rectangle(DestContext, R.Left + Target.x, R.Top + Target.y,
            R.Right - R.Left, R.Bottom - R.Top);
          cairo_fill(DestContext);

          cairo_destroy(DestContext);
        end;
      end;
  end;
end;

function CalculateScanline(Bits: Pointer; Width, Height, Row: Integer): Pointer;
begin
  Result := nil;
end;

function GetBitmapBitsFromBitmap(Bitmap: HBITMAP): Pointer;
begin
  Result := nil;
end;