⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xgraphics.pas

📁 关于c++ builder编程的很好的资料
💻 PAS
字号:
unit xGraphics;

interface

uses Windows, Messages, SysUtils, Forms, Controls, Graphics, ShellAPI, Registry, Math, Dialogs;

function ColorToRGBString(AColor: TColor): string;
function RGBStringToColor(RGBStr: string): TColor;

function MyLoadIcon(const Filename: string; DefaultIcon: THandle = 0): THandle;
procedure GetIconBits(IconHandle: HICON; Bits: TBitmap);

function CursorToIcon(const hc: THandle; bDestroyCursor: Boolean = False): THandle;

function ColorNumToStr(Num: Integer): string;
function ColorDiff(C1, C2: TColor): Integer;

procedure ReplaceBitmapColor(Bits: TBitmap; FromColor, ToColor: COLORREF);

function ColorToHexStr(C: TColor): string;
function HexStrToColor(S: string): TColor;

function ContrastColor(const mc: TColor): TColor;
function OppositeColor(C: TColor): TColor;

implementation

uses xUtils, xStrings, xFiles;

function ColorToRGBString(AColor: TColor): string;
begin
  Result := Format('%d %d %d',[GetRValue(AColor), GetGValue(AColor), GetBValue(AColor)]);
end;

function RGBStringToColor(RGBStr: string): TColor;
var
  I      : Integer;
  R, G, B: Byte;   
begin
  Result := $00000000;
  RGBStr := Trim(RGBStr);
  if CountWords(RGBStr) <> 3 then Exit;
  
  // Red Value
  I := Pos(' ', RGBStr);
  R := StrToIntDef(Copy(RGBStr, 1, I - 1), 0);
  Delete(RGBStr, 1, I);
  
  // Green Value
  I := Pos(' ', RGBStr);
  G := StrToIntDef(Copy(RGBStr, 1, I - 1), 0);
  Delete(RGBStr, 1, I);
  
  // Blue
  B := StrToIntDef(RGBStr, 0);
  
  Result := RGB(R, G, B);
end;

function MyLoadIcon(const Filename: string; DefaultIcon: THandle = 0): THandle;
var
  IconNo: Integer;
  S, Ext: string; 
begin
  Result := 0;
  
  S := AnsiUpperCase(Filename);
  IconNo := TruncateTrailNumber(S);
  
  Ext := ExtractFileExt(S);
  if Ext = '.ICO' then
    Result := LoadImage(HInstance, PChar(S), IMAGE_ICON, 32, 32,
    LR_LOADFROMFILE)
  else if ((Ext = '.ICL') or (Ext = '.DLL') or (Ext = '.EXE'))
    and (IconNo <> -1) then
    Result := ExtractIcon(HInstance, PChar(S), IconNo);
  
  // 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -