亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ggraphiccolor.pas

?? [原創]這是我寫的一個圖像組件!組件中使用了GraphicEx庫
?? PAS
?? 第 1 頁 / 共 5 頁
字號:
unit GGraphicColor;

// The contents of this file are subject to the Mozilla Public License
// Version 1.1 (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
// specific language governing rights and limitations under the License.
//
// The original code is GraphicColor.pas, released November 1, 1999.
//
// The initial developer of the original code is Dipl. Ing. Mike Lischke (Plei遖, Germany, www.delphi-gems.com),
//
// Portions created by Dipl. Ing. Mike Lischke are Copyright
// (C) 1999-2003 Dipl. Ing. Mike Lischke. All Rights Reserved.
//----------------------------------------------------------------------------------------------------------------------
// This file is part of the image library GraphicEx.
//
// GraphicColor contains the implementation of the color conversion manager.
// This class is responsible for converting between these color schemes/formats:
//   - RGB(A)
//   - BGR(A)
//   - CMY(K)
//   - CIE L*a*b*
//   - PhotoYCC, standard YCbCr
//   - indexed
//   - grayscale (with alpha, which is ignored currently)
//
// Additional tasks are:
//   - coversions between bit depths (1, 2, 4, 8, 16 bits)
//   - palette creation
//   - gamma tables creation and application
//   - masked pixel transfer for interlaced images
//   - big endian swap
//   - plane (planar) -> interleaved (interlaced) conversion
//
// Notes:
//   - Throughout the entire unit I used the terms BPS and SPP for "bits per sample" and
//     "samples per pixel", respectively. A sample is one component per pixel. For indexed color schemes
//     there's only 1 sample per pixel, for RGB there are 3 (red, green and blue) and so on.
//   - The bit depth of multi sample formats like RGB must be equal for each color component.
//   - Because of the large amount of possible combinations (color schemes, sample depth, gamma, byte swap)
//     I limited the accepted combinations to pratical ones. This leaves currently out:
//       + gamma correction for 16 bit values
//       + conversion to 16 bit (target) grayscale with alpha
//       + samples sizes less than 8 bits for multi-sample schemes (RGB etc.)
//       + indexed schemes with planes (e.g. 16 colors indexed as 4 planes each with one bit per sample)
//   - For now there is no conversion between indexed and non-indexed formats. Also between grayscale
//     and any other scheme is no conversion possible.
//
//----------------------------------------------------------------------------------------------------------------------

interface

{$I GGraphicConfiguration.inc}

uses
  Windows, Graphics, GGraphicStrings;

const
  // this is the value for average CRT monitors, adjust it if your monitor differs
  DefaultDisplayGamma = 2.2;

type
  TColorScheme = (
    csUnknown,   // not (yet) defined color scheme
    csIndexed,   // any palette format
    csG,         // gray scale
    csGA,        // gray scale with alpha channel
    csRGB,       // red, green, blue
    csRGBA,      // RGB with alpha channel
    csBGR,       // RGB in reversed order (used under Windows)
    csBGRA,      // BGR with alpha channel (alpha is always the last component)
    csCMY,       // cyan, magenta, yellow (used mainly for printing processes)
    csCMYK,      // CMY with black
    csCIELab,    // CIE color format using luminance and chromaticities
    csYCbCr,     // another format using luminance and chromaticities
    csPhotoYCC   // a modified YCbCr version used for photo CDs
  );
  
  TConvertOptions = set of (
    coAlpha,          // alpha channel is to be considered (this value is usually automatically set depending on
                      // the color scheme)
    coApplyGamma,     // target only, gamma correction must take place
    coNeedByteSwap,   // endian switch needed
    coLabByteRange,   // CIE L*a*b* only, luminance range is from 0..255 instead 0..100
    coLabChromaOffset // CIE L*a*b* only, chrominance values a and b are given in 0..255 instead -128..127
  );

  // format of the raw data to create a color palette from
  TRawPaletteFormat = (
    pfInterlaced8Triple, // rgb triple with 8 bits per component
    pfInterlaced8Quad,   // rgb quad with 8 bits per component (fourth entry is reserved as in Windows' logical palette)
    pfPlane8Triple,      // 3 separate planes of data with 8 bits per component
    pfPlane8Quad,
    pfInterlaced16Triple,// rgb triple with 16 bits per component
    pfInterlaced16Quad,
    pfPlane16Triple,     // 3 separate planes of data with 16 bits per component
    pfPlane16Quad
  );

  // TConversionMethod describes the general parameter list to which each implemented conversion method conforms.
  // Note: Source is defined as open array parameter to allow plane and interlaced source data.
  TConversionMethod = procedure(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte) of object;
  
  TColorManager = class
  private
    FChanged: Boolean;                 // set if any of the parameters changed
    FSourceBPS,                        // bits per sample of source data (allowed values are 1, 2, 4, 8, 16)
    FTargetBPS,                        // bits per sample of target data (allowed values are 1, 2, 4, 8, 16)
    FSourceSPP,                        // samples per source pixel (allowed values are 1, 3, 4)
    FTargetSPP: Byte;                  // samples per target pixel (allowed values are 1, 3, 4)
    FMainGamma,                        // primary gamma value which is usually read from a file (default is 1)
    FDisplayGamma: Single;             // (constant) gamma value of the current monitor (default is 2.2)
    FGammaTable: array[Byte] of Byte;  // contains precalculated gamma values for each possible component value
                                       // (range is 0..255)
    FYCbCrCoefficients: array[0..2] of Single;
    FHSubsampling,
    FVSubSampling: Byte;               // additional parameters used for YCbCr conversion
    FCrToRedTable,                     // lookup tables used for YCbCr conversion
    FCbToBlueTable,
    FCrToGreenTable,                                       
    FCbToGreenTable: array of Integer;

    FSourceScheme,
    FTargetScheme: TColorScheme;
    FRowConversion: TConversionMethod; // procedure variable for the actual conversion method used
    FSourceOptions,
    FTargetOptions: TConvertOptions;   // options to control conversion
  protected
    // Low level conversion helper used to convert one pixel component.
    function ComponentGammaConvert(Value: Byte): Byte;
    function ComponentNoConvert16(Value: Word): Word;
    function ComponentNoConvert8(Value: Byte): Byte;
    function ComponentScaleConvert(Value: Word): Byte;
    function ComponentScaleGammaConvert(Value: Word): Byte;
    function ComponentSwapScaleGammaConvert(Value: Word): Byte;
    function ComponentSwapScaleConvert(Value: Word): Byte;
    function ComponentSwapConvert(Value: Word): Word;

    // row conversion routines
    procedure RowConvertBGR2BGR(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertBGR2RGB(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertCIELAB2BGR(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertCIELAB2RGB(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertCMYK2BGR(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertCMYK2RGB(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertGray(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertIndexed8(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertIndexedBoth16(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertIndexedSource16(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertIndexedTarget16(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertRGB2BGR(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertRGB2RGB(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertPhotoYCC2BGR(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertPhotoYCC2RGB(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertYCbCr2BGR(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    procedure RowConvertYCbCr2RGB(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);

    // other general routines
    procedure CreateYCbCrLookup;
    function GetPixelFormat(Index: Integer): TPixelFormat;
    procedure PrepareConversion;
    procedure SetSourceBitsPerSample(const Value: Byte);
    procedure SetSourceColorScheme(const Value: TColorScheme);
    procedure SetSourceSamplesPerPixel(const Value: Byte);
    procedure SetTargetBitsPerSample(const Value: Byte);
    procedure SetTargetColorScheme(const Value: TColorScheme);
    procedure SetTargetSamplesPerPixel(const Value: Byte);
  public
    constructor Create;

    procedure ConvertRow(Source: array of Pointer; Target: Pointer; Count: Cardinal; Mask: Byte);
    function CreateColorPalette(Data: array of Pointer; DataFormat: TRawPaletteFormat; ColorCount: Cardinal;
      RGB: Boolean): HPALETTE;
    function CreateGrayscalePalette(MinimumIsWhite: Boolean): HPALETTE;
    procedure Error(const Msg: String);
    procedure SetGamma(MainGamma: Single; DisplayGamma: Single = DefaultDisplayGamma);
    procedure SetYCbCrParameters(Values: array of Single; HSubSampling, VSubSampling: Byte);

    property SourceBitsPerSample: Byte read FSourceBPS write SetSourceBitsPerSample;
    property SourceColorScheme: TColorScheme read FSourceScheme write SetSourceColorScheme;
    property SourceOptions: TConvertOptions read FSourceOptions write FSourceOptions;
    property SourcePixelFormat: TPixelFormat index 0 read GetPixelFormat;
    property SourceSamplesPerPixel: Byte read FSourceSPP write SetSourceSamplesPerPixel;
    property TargetBitsPerSample: Byte read FTargetBPS write SetTargetBitsPerSample;
    property TargetColorScheme: TColorScheme read FTargetScheme write SetTargetColorScheme;
    property TargetOptions: TConvertOptions read FTargetOptions write FTargetOptions;
    property TargetPixelFormat: TPixelFormat index 1 read GetPixelFormat;
    property TargetSamplesPerPixel: Byte read FTargetSPP write SetTargetSamplesPerPixel;
  end;

function ClampByte(Value: Integer): Byte;
function MulDiv16(Number, Numerator, Denominator: Word): Word;
  
//----------------------------------------------------------------------------------------------------------------------

implementation

uses
  Math, SysUtils;

type
  EColorConversionError = class(Exception);

  PCMYK = ^TCMYK;
  TCMYK = packed record
    C, M, Y, K: Byte;
  end;

  PCMYK16 = ^TCMYK16;
  TCMYK16 = packed record
    C, M, Y, K: Word;
  end;

  PCMY = ^TCMY;
  TCMY = packed record
    C, M, Y: Byte;
  end;

  PCMY16 = ^TCMY16;
  TCMY16 = packed record
    C, M, Y: Word;
  end;
  
  PRGB = ^TRGB;
  TRGB = packed record
    R, G, B: Byte;
  end;

  PRGB16 = ^TRGB16;
  TRGB16 = packed record
    R, G, B: Word;
  end;

  PRGBA = ^TRGBA;
  TRGBA = packed record
    R, G, B, A: Byte;
  end;

  PRGBA16 = ^TRGBA16;
  TRGBA16 = packed record
    R, G, B, A: Word;
  end;

  PBGR = ^TBGR;
  TBGR = packed record
    B, G, R: Byte;
  end;

  PBGR16 = ^TBGR16;
  TBGR16 = packed record
    B, G, R: Word;
  end;

  PBGRA = ^TBGRA;
  TBGRA = packed record
    B, G, R, A: Byte;
  end;

  PBGRA16 = ^TBGRA16;
  TBGRA16 = packed record
    B, G, R, A: Word;
  end;

//----------------- helper functions -----------------------------------------------------------------------------------

function ClampByte(Value: Integer): Byte;

// ensures Value is in the range 0..255, values < 0 are clamped to 0 and values > 255 are clamped to 255

asm
         OR EAX, EAX
         JNS @@positive
         XOR EAX, EAX
         RET

@@positive:
         CMP EAX, 255
         JBE @@OK
         MOV EAX, 255
@@OK:
end;

//----------------------------------------------------------------------------------------------------------------------

function MulDiv16(Number, Numerator, Denominator: Word): Word;

// faster equivalent to Windows' MulDiv function
// Number is passed via AX
// Numerator is passed via DX
// Denominator is passed via CX
// Result is passed via AX
// Note: No error checking takes place. Denominator must be > 0!

asm
         MUL DX
         DIV CX
end;

//----------------- TColorManager --------------------------------------------------------------------------------------

constructor TColorManager.Create;

// set some default values

begin
  FSourceBPS := 8;
  FTargetBPS := 8;                             
  FSourceSPP := 3; // 24 bit format
  FTargetSPP := 3; // 24 bit format
  SetGamma(1, DefaultDisplayGamma);
  FSourceScheme := csRGB;
  FTargetScheme := csBGR;

  // defaults are from CCIR Recommendation 601-1
  FYCbCrCoefficients[0] := 0.299;
  FYCbCrCoefficients[1] := 0.587;
  FYCbCrCoefficients[2] := 0.114;

  FHSubSampling := 1;
  FVSubSampling := 1;

  FChanged := True;
end;

//----------------- low level conversion routines ----------------------------------------------------------------------

// These routines are used for conversions from 16 to 8 bit values, either with gamma correction or byte swap (or both).

function TColorManager.ComponentNoConvert8(Value: Byte): Byte;

begin
  Result := Value;
end;

//----------------------------------------------------------------------------------------------------------------------

function TColorManager.ComponentNoConvert16(Value: Word): Word;

begin
  Result := Value;
end;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
不卡一区二区在线| 成人免费视频视频在线观看免费| 国产欧美日韩在线| 欧美精品一区二区在线观看| 久久伊99综合婷婷久久伊| 欧美变态tickling挠脚心| 精品久久久久久久久久久久久久久 | proumb性欧美在线观看| 菠萝蜜视频在线观看一区| 成人综合激情网| 91丨九色丨蝌蚪富婆spa| 色一情一伦一子一伦一区| 欧美色男人天堂| 91精品国产色综合久久不卡蜜臀 | 91精品久久久久久久久99蜜臂| 欧美日韩一级视频| 欧美成人伊人久久综合网| 2020日本不卡一区二区视频| 国产亚洲欧美一区在线观看| 亚洲欧美国产77777| 水蜜桃久久夜色精品一区的特点| 久久电影网电视剧免费观看| 丁香亚洲综合激情啪啪综合| 日本韩国欧美国产| 欧美成人精品1314www| 国产视频一区在线播放| 一区二区三区欧美| 麻豆国产欧美一区二区三区| www.欧美亚洲| 欧美一级欧美三级| 中文字幕一区av| 日本成人中文字幕在线视频| 国产成人免费av在线| 欧美视频日韩视频在线观看| 国产亚洲婷婷免费| 石原莉奈一区二区三区在线观看| 国产成人自拍高清视频在线免费播放| 91在线国产福利| 2023国产精品视频| 午夜影院久久久| 93久久精品日日躁夜夜躁欧美| 欧美日韩一区 二区 三区 久久精品| 日韩视频免费直播| 一区二区三区在线视频免费观看 | 国产日韩欧美高清在线| 亚洲午夜成aⅴ人片| 国产成人av网站| 日韩一级在线观看| 一区二区国产视频| 99re热视频这里只精品| 精品久久久久久久人人人人传媒| 亚洲一区二区四区蜜桃| 成人aaaa免费全部观看| 久久精品一区二区三区不卡| 亚洲mv在线观看| 日本韩国一区二区| 一区免费观看视频| 成人h精品动漫一区二区三区| 欧美精品一区二区三区一线天视频| 亚洲国产aⅴ天堂久久| 色综合天天综合网国产成人综合天| 久久久久久久久97黄色工厂| 美女视频黄 久久| 91精品国产一区二区三区蜜臀| 一区二区成人在线| 日本韩国欧美在线| 亚洲精品成人在线| 91黄色免费版| 亚洲一区二区三区免费视频| 色综合久久久久网| 亚洲精品欧美激情| 欧美日韩在线一区二区| 亚洲大片在线观看| 日韩午夜激情电影| 国产在线国偷精品免费看| 日韩一区二区三区在线观看| 日韩av不卡在线观看| 日韩免费高清av| 国产在线观看一区二区| 久久精品人人做人人综合 | 国产成人在线色| 国产欧美日韩亚州综合| av一区二区三区在线| 亚洲欧洲美洲综合色网| 日本韩国精品在线| 日韩av电影一区| 久久久久久亚洲综合| www.亚洲精品| 亚洲自拍偷拍网站| 日韩欧美中文字幕精品| 国产一区二区免费看| 中文字幕一区二区三区蜜月| 欧美私模裸体表演在线观看| 日韩综合小视频| 久久久久青草大香线综合精品| 国产成人激情av| 亚洲高清视频在线| 日韩一区二区三区观看| 成a人片亚洲日本久久| 亚洲高清三级视频| 久久综合九色综合97婷婷女人| 99在线精品观看| 日本欧美大码aⅴ在线播放| 久久精品视频网| 欧美偷拍一区二区| 国产精品资源网| 亚洲国产美女搞黄色| 精品国产自在久精品国产| 99re成人在线| 久久精品99国产精品日本| 亚洲另类中文字| 久久人人爽人人爽| 欧美日韩视频第一区| 国产成人鲁色资源国产91色综 | 同产精品九九九| 欧美韩日一区二区三区四区| 欧美精品1区2区| 91亚洲午夜精品久久久久久| 美日韩黄色大片| 亚洲午夜私人影院| 国产精品私人影院| 精品奇米国产一区二区三区| 色婷婷激情综合| 成人动漫一区二区| 国产一区二区视频在线| 日韩一区欧美二区| 一区二区三区日本| 欧美国产成人在线| 精品成人一区二区| 日韩三级视频在线观看| 欧美丝袜丝交足nylons图片| 91丨九色丨尤物| av不卡在线播放| 国产成人精品一区二区三区四区| 日韩精品五月天| 亚洲成人av免费| 亚洲一区二区美女| 亚洲精品国产成人久久av盗摄 | 欧洲日韩一区二区三区| 成人三级在线视频| 成人一区在线看| 福利一区福利二区| 国产精品亚洲综合一区在线观看| 美国三级日本三级久久99| 日韩电影免费在线看| 成人小视频免费观看| 日韩电影免费在线观看网站| 天天综合色天天| 午夜精彩视频在线观看不卡| 亚洲一区二区欧美日韩| 亚洲国产精品欧美一二99| 亚洲在线视频免费观看| 一区二区三区在线免费| 亚洲一区二区三区爽爽爽爽爽| 亚洲欧美偷拍三级| 亚洲最大的成人av| 亚洲一二三区视频在线观看| 亚洲午夜精品网| 日本在线不卡一区| 久久精品国产秦先生| 国产一区二区剧情av在线| 国产乱人伦偷精品视频不卡| 国产成人小视频| 91视频在线观看| 欧美日韩专区在线| 欧美大片在线观看一区| 国产亚洲欧美色| 亚洲欧洲综合另类在线| 午夜精品免费在线观看| 麻豆国产欧美日韩综合精品二区| 极品尤物av久久免费看| 春色校园综合激情亚洲| 91猫先生在线| 日韩一区二区电影网| 欧美激情综合网| 五月综合激情网| 国产精品影视天天线| 欧美综合天天夜夜久久| 精品久久久久久综合日本欧美| 国产精品麻豆欧美日韩ww| 亚洲影院理伦片| 国产一区视频导航| 欧美综合在线视频| 久久综合久久综合久久综合| 亚洲欧美激情在线| 精品一区二区在线视频| 99久久婷婷国产| 日韩美一区二区三区| 亚洲精品成人在线| 国产精品一区二区不卡| 欧美日韩在线播放| 国产精品嫩草久久久久| 亚洲最新视频在线观看| 国产精品一区二区三区乱码| 91麻豆自制传媒国产之光| 日韩欧美专区在线| 亚洲一区二区精品视频| 不卡在线观看av| 精品av综合导航| 日日欢夜夜爽一区|