AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Projekte [nonVCL] Graphics- Unit Lite

[nonVCL] Graphics- Unit Lite

Ein Thema von turboPASCAL · begonnen am 22. Aug 2009 · letzter Beitrag vom 22. Aug 2009
Antwort Antwort
Seite 1 von 2  1 2   
Benutzerbild von turboPASCAL
turboPASCAL
Registriert seit: 8. Mai 2005
Hi,

ich habe gerade eine kleine Unit for nonVCL zusammen gebastelt, um mir den Umgang
bei dem Zeichnen von Graphiken zu erleichtern.

Wer's brauch oder gebrauchen kann, bitte:

Delphi-Quellcode:
{*******************[        uNVCLGraphics for nonVCL        ]*****************}
{                                  Version 1.0                                 }
{                                                                              }
{               __                                                             }
{   ...by      / /_____                                                        }
{            / __/ __ \                                                        }
{           / /_/ /_/ /                                                        }
{          \__/  ___/                                                          }
{            /_/          turboPASCAL (tp) aka MatthiasG.                      }
{                                Member of [url]www.delphipraxis.net[/url]                }
{                                                                              }
{*********************************[    2009    ]*******************************}

unit uNVCLGraphics; {Lite}

{.$DEFINE USE_IMAGES}
{.$DEFINE NON_VCL_TOOLS_UNIT}

interface

{$IFDEF NON_VCL_TOOLS_UNIT}
uses
  Windows
  nonVCLTools;
{$ELSE}
uses
  Windows;
{$ENDIF}

const
  clBlack = $00000000;
  clWhite = $00FFFFFF;
 
  clLGray = $00808080;
  clGray = $00C0C0C0;
  clDGray = $00404040;

  clRed = $000000FF;
  clLRed = $008080FF;
  clDRed = $00000080;

  clGreen = $0000FF00;
  clLGreen = $0080FF80;
  clDGreen = $00008000;

  clBlue = $00FF0000;
  clLBlue = $00FF8080;
  clDBlue = $00800000;

  clYellow = $0000FFFF;
  clDYellow = $00004040;


type
  TPenStyle = (psSolid, psDash, psDot, psDashDot, psDashDotDot, psClear);

  TFontStyle = (fsBold, fsItalic, fsUnderline, fsStrikeOut);
  TFontStyles = set of TFontStyle;

type
  TPen = class
  private
    DC: HDC;
    penColor: Cardinal;
    penStyle: TPenStyle;
    penWidth: integer;
    procedure ReCreate;
    procedure SetPenStyle(Style: TPenStyle);
    procedure SetPenWidth(Width: integer);
    procedure SetPenColor(Color: Cardinal);
  public
    Handle: HPEN;
    constructor Create(DCHandle: HDC);
    destructor Destroy; override;

    property Color: Cardinal read penColor write SetPenColor;
    property Style: TPenStyle read penStyle write SetPenStyle;
    property Width: integer read penWidth write SetPenWidth;
  end;

  TBrush = class
  private
    DC: HDC;
    brushColor: Cardinal;
    procedure ReCreate;
  public
    Handle: HBRUSH;
    constructor Create(DCHandle: HDC);
    destructor Destroy; override;
    procedure SetColor(Color: Cardinal);

    property Color: Cardinal read brushColor write SetColor;
  end;

  TFont = class
  private
    DC: HDC;
    fontName: string;
    fontSize: integer;
    fontStyle: TFontStyles;
    fontColor: Cardinal;
    fontOrientation: integer;
    lf: TLogFont;
    procedure SetName(Name: string);
    procedure SetSize(Size: integer);
    procedure SetStyle(Style: TFontStyles);
    procedure SetColor(Color: Cardinal);
    procedure SetOrientation(Orientation: integer);

    procedure ReCreate;
  public
    Handle: HFONT;
    constructor Create(DCHandle: HDC);
    destructor Destroy; override;

    property Name: string read fontName write SetName;
    property Size: integer read fontSize write SetSize;
    property Color: Cardinal read fontColor write SetColor;
    property Style: TFontStyles read fontStyle write SetStyle;
    property Orientation: integer read fontOrientation write SetOrientation;
  end;

type
  TGraphic = class
  private
    Wnd: HWND;
    gDC: HDC;
    BoundsRect: TRect;

    pBmpBits: pointer;
    BmpInfo: BITMAPINFO;
    hBmp: HBITMAP;
  public
    Pen: TPen;
    Brush: TBrush;
    Font: TFont;
    constructor Create(DCHandle: HDC; WndHandle: HWND; Left, Top, Width, Height: integer);
    destructor Destroy; override;

    function CreateGraphicBitmap(var BmpInfo: BITMAPINFO; const W, H: Integer; out BitmapBits: Pointer): HBITMAP;
    procedure Line(x1, y1, x2, y2: integer);
    procedure FillRect(r: TRect);
    procedure Ellipse(x1, y1, x2, y2: integer);
    procedure RoundRect(x1, y1, x2, y2, r1, r2: integer);
    procedure FrameRect(x1, y1, x2, y2: integer); overload;
    procedure FrameRect(Rect: TRect); overload;
    procedure Rectangle(x1, y1, x2, y2: integer);
    procedure SetPixel(x, y: integer; Color: Cardinal);
    function GetPixel(x, y: integer): Cardinal;
    procedure TextOut(x, y: integer; Text: string);
    procedure DrawTo(DC: HDC; x, y: integer);
    procedure StretchDrawTo(DC: HDC; x1, y1, x2, y2: integer);

    procedure Invalidate(const EraseBackround: Boolean = FALSE);

    {$IFDEF USE_IMAGES}
      procedure LoadImageFromFile(Filename: string);
      procedure LoadImageFromResourceID(Instance: HInst; ResID: Integer);
      procedure LoadImageFromResourceName(Instance: HInst; ResName: PChar);
    {$ENDIF USE_IMAGES}

    // property Pixels: ... read GetPixels write Cardinal;
    property Bits: Pointer read pBmpBits;
  end;

{$IFNDEF NON_VCL_TOOLS_UNIT}
  function Point(X, Y: Integer): TPoint;
  function Rect(X1, Y1, X2, Y2: Integer): TRECT;
{$ENDIF NON_VCL_TOOLS_UNIT}

implementation

{...}
Angehängte Dateien
Dateityp: exe test_120.exe (18,5 KB, 42x aufgerufen)
Dateityp: zip unvclgraphics.source_demo_124.zip (5,5 KB, 69x aufgerufen)
Meine Software-Projekte - Homepage - Grüße vom Rüsselmops -Mops Mopser
 
Benutzerbild von Luckie
Luckie

 
Delphi 2006 Professional
 
#2
  Alt 22. Aug 2009, 18:04
Würdest du bitte den Code als Datei anhängen? So im Beitrag bringt das irgendwie nicht viel und macht ihn nur unübersichtlich.
Michael
  Mit Zitat antworten Zitat
Benutzerbild von turboPASCAL
turboPASCAL

 
Delphi 6 Personal
 
#3
  Alt 22. Aug 2009, 18:11
Ja, natürlich. Habe es gerade bemerkt und korrigiert.
Matti
  Mit Zitat antworten Zitat
Benutzerbild von mschaefer
mschaefer

 
Delphi XE3 Enterprise
 
#4
  Alt 22. Aug 2009, 18:18
Moin moin,

gute Idee Matti. Sowas kann man immer mal wieder brauchen.
Wenn Du das Tesprojekt schon hast, dann lege es doch bei.

Grüße // Martin
Martin Schaefer
  Mit Zitat antworten Zitat
Apollonius

 
Turbo Delphi für Win32
 
#5
  Alt 22. Aug 2009, 18:24
Es heißt "Orientation", nicht "Orirentation".
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

 
Delphi 11 Alexandria
 
#6
  Alt 22. Aug 2009, 18:34
Erbsenzähler
Detlef
  Mit Zitat antworten Zitat
Benutzerbild von turboPASCAL
turboPASCAL

 
Delphi 6 Personal
 
#7
  Alt 22. Aug 2009, 18:37
Zitat von DeddyH:
Erbsenzähler
Dito. {Oder Autorenfreiheit}


@mschaefer, ja ich mach gerade ein Demodings.
Matti
  Mit Zitat antworten Zitat
Benutzerbild von mschaefer
mschaefer

 
Delphi XE3 Enterprise
 
#8
  Alt 22. Aug 2009, 19:12
Naja das hat Mendel ja auch schon gemacht. Aber wegen sowas wünsche ich mir eigentlich einen Beitragsmarker,
der den Beitrag nach 20 Minuten verschwinden lässt. Fehler die Weg sind sind nicht verewigt...

Aber zur Unit:
Gerade als GUI von Commandlinetools und Wartungsroutinen ist das mit der NonVcl eine feine Sache. Und das läuft sogar auf ReactOS!

Grüße // Martin


PS: Auf das Demoddings bin ich schon gespannt ...
Martin Schaefer
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

 
Delphi 11 Alexandria
 
#9
  Alt 22. Aug 2009, 19:15
Zitat von turboPASCAL:
Zitat von DeddyH:
Erbsenzähler
Dito. {Oder Autorenfreiheit}
Öhmm... wie soll ich das deuten? Ich bezog mich auf #5
Detlef
  Mit Zitat antworten Zitat
Benutzerbild von turboPASCAL
turboPASCAL

 
Delphi 6 Personal
 
#10
  Alt 22. Aug 2009, 19:25
Immer mit der Ruhe.
Ich auch, ich auch...
Matti
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2   

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:29 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz