zoukankan      html  css  js  c++  java
  • GdiPlus[45]: IGPGraphics (四) 关于呈现质量与合成模式


    相关内容有:
    IGPGraphics.SmoothingMode;            { 绘图质量 }
    IGPGraphics.InterpolationMode;        { 插补模式 }
    IGPGraphics.CompositingMode;          { 前景色与背景色的合成混合模式 }
    IGPGraphics.CompositingQuality;       { 图像合成质量 }
    IGPGraphics.PixelOffsetMode;          { 像素的偏移模式 }
    
    { 文本的呈现质量要用 }
    IGPGraphics.TextRenderingHint;        { 文本呈现模式 }
    IGPGraphics.TextContrast;             { 文本灰度校正值(消除锯齿和 ClearType 文本的伽玛值校正) }
    

    相关参数:
    SmoothingMode { 对直线、曲线和已填充区域的边缘采用锯齿消除功能, 它不能控制路径渐变画笔 }
    Invalid     // 一个无效模式  
    Default     // 不消除锯齿, 等效于 HighSpeed、None
    HighSpeed   // 不消除锯齿  
    HighQuality // 消除锯齿, 等效于 AntiAlias
    None        // 不消除锯齿  
    AntiAlias   // 消除锯齿
    
    InterpolationMode { 插补模式确定如何计算两个像素点之间的中间值 } Invalid // 等效于 QualityMode 枚举的 Invalid 元素. Default // 默认模式. Low // 低质量插值法. High // 高质量插值法. Bilinear // 双线性插值法; 不进行预筛选; 将图像收缩为原始大小的 50% 以下时此模式不适用. Bicubic // 双三次插值法; 不进行预筛选; 将图像收缩为原始大小的 25% 以下时此模式不适用. NearestNeighbor // 最临近插值法. HighQualityBilinear // 高质量的双线性插值法; 执行预筛选以确保高质量的收缩. HighQualityBicubic // 高质量的双三次插值法; 执行预筛选以确保高质量的收缩; 可产生质量最高的转换图像.
    CompositingMode { 颜色合成模式 } SourceOver // 与背景色混合; 该混合由透明度确定 SourceCopy // 改写背景色
    CompositingQuality { 图像合成时, 源像素与目标像素和合成方式 } Invalid // 无效质量 Default // 默认质量 HighSpeed // 高速度、低质量 HighQuality // 高质量、低速度复合 GammaCorrected // 使用灰度校正 AssumeLinear // 假定线性值
    PixelOffsetMode { 像素偏移模式 } Invalid // 无效模式. Default // 默认模式. HighSpeed // 高速度、低质量呈现. HighQuality // 高质量、低速度呈现. None // 没有任何像素偏移. Half // 像素在水平和垂直距离上均偏移 -0.5 个单位, 以进行高速锯齿消除.

    SmoothingMode 测试:



    uses GdiPlus;
    
    procedure TForm1.FormPaint(Sender: TObject);
    var
      Graphics: IGPGraphics;
      Pen: IGPPen;
      Rect: TGPRectF;
      i: Integer;
    begin
      Graphics := TGPGraphics.Create(Handle);
      Pen := TGPPen.Create($FFB22222, 4);
      Rect.Initialize(ClientWidth * 3/8, ClientHeight * 3/8, ClientWidth / 4, ClientHeight / 4);
    
      for i := 0 to 4 do
      begin
        Graphics.SmoothingMode := TGPSmoothingMode(i);
        Graphics.DrawEllipse(Pen, Rect);
        Rect.Inflate(ClientWidth / 14, ClientHeight / 14);
      end;
    end;
    

    InterpolationMode 测试:



    uses GdiPlus;
    
    procedure TForm1.FormPaint(Sender: TObject);
    var
      Graphics: IGPGraphics;
      Image: IGPImage;
      Rect: TGPRectF;
      i: Integer;
    begin
      Graphics := TGPGraphics.Create(Handle);
      Image := TGPImage.Create('C:\GdiPlusImg\Grapes.jpg');
      Rect.Initialize(10, 10, Image.Width * 0.5, Image.Height * 0.5);
    
      for i := 0 to 7 do
      begin
        Graphics.InterpolationMode := TGPInterpolationMode(i);
        Graphics.DrawImage(Image, Rect);
        Rect.Offset(Rect.Width + 10, 0);
        if Rect.X + Rect.Width > ClientWidth then
        begin
          Rect.X := 10;
          Rect.Offset(0, Rect.Height + 10);
        end;
      end;
    end;
    
    procedure TForm1.FormResize(Sender: TObject);
    begin
      Repaint;
    end;
    

    CompositingMode 测试:



    uses GdiPlus;
    
    procedure TForm1.FormPaint(Sender: TObject);
    var
      Graphics: IGPGraphics;
      Brush: IGPLinearGradientBrush;
      Rect: TGPRect;
    begin
      Graphics := TGPGraphics.Create(Handle);
      Rect.Initialize(20, 20, 200, 60);
      Brush := TGPLinearGradientBrush.Create(Rect, $FFA52A2A, $FFFFFF00, 0);
    
      Graphics.CompositingMode := CompositingModeSourceOver; //默认模式
      Graphics.FillRectangle(Brush, Rect);
    
      Brush := TGPLinearGradientBrush.Create(Rect, $80A52A2A, $80FFFF00, 0);
    
      Graphics.CompositingMode := CompositingModeSourceOver;
      Rect.Offset(0, 20 + Rect.Height);
      Graphics.FillRectangle(Brush, Rect);
    
      Graphics.CompositingMode := CompositingModeSourceCopy;
      Rect.Offset(0, 20 + Rect.Height);
      Graphics.FillRectangle(Brush, Rect);
    end;
    

    CompositingQuality 测试:



    uses GdiPlus;
    
    procedure TForm1.FormPaint(Sender: TObject);
    var
      Graphics: IGPGraphics;
      Image: IGPImage;
      Rect: TGPRectF;
      Brush: IGPSolidBrush;
      i: Integer;
    begin
      Graphics := TGPGraphics.Create(Handle);
      Image := TGPImage.Create('C:\GdiPlusImg\Grapes.jpg');
      Rect.Initialize(10, 10, Image.Width * 0.75, Image.Height * 0.75);
      Brush := TGPSolidBrush.Create($800000FF);
    
      for i := 0 to 4 do
      begin
        Graphics.CompositingQuality := TGPCompositingQuality(i);
        Graphics.DrawImage(Image, Rect);
        Graphics.FillRectangle(Brush, Rect);
    
        Rect.Offset(Rect.Width + 10, 0);
        if Rect.X + Rect.Width > ClientWidth then
        begin
          Rect.X := 10;
          Rect.Offset(0, Rect.Height + 10);
        end;
      end;
    end;
    
    procedure TForm1.FormResize(Sender: TObject);
    begin
      Repaint;
    end;
    

    PixelOffsetMode 测试:



    uses GdiPlus;
    
    procedure TForm1.FormPaint(Sender: TObject);
    var
      Graphics: IGPGraphics;
      BrushBack: IGPHatchBrush;
      Brush: IGPSolidBrush;
      Rect: TGPRectF;
      i: Integer;
    begin
      Graphics := TGPGraphics.Create(Handle);
      BrushBack := TGPHatchBrush.Create(HatchStyleCross, $FFD0D0D0, $FFFFFFFF);
      Graphics.FillRectangle(BrushBack, TGPRect.Create(ClientRect));
    
      Rect.Initialize(0.34, 1, 5.1, 1.3);
      Brush := TGPSolidBrush.Create($80FF0000);
    
      Graphics.ScaleTransform(27.3, 17.3);
      for i := 0 to 4 do
      begin
        Graphics.PixelOffsetMode := TGPPixelOffsetMode(i);
        Graphics.FillRectangle(Brush, Rect);
        Rect.Offset(0, Rect.Height + 1);
      end;
    end;
    
  • 相关阅读:
    ASP.NET 分页数据源:: PagedDataSource //可分页数据源
    strtok
    FloydWarshall算法详解(转)
    Tom Clancy's Splinter Cell: Double Agent
    暴雪COO确认:星际争霸2.0要来了
    wxWidgets 2.8.0 released
    如饥似渴
    大乘法器遇见小乘法器
    GLEW 1.3.5 adds OpenGL 2.1 and NVIDIA G80 extensions
    DevIL真是好用得想哭
  • 原文地址:https://www.cnblogs.com/del/p/1630120.html
Copyright © 2011-2022 走看看