zoukankan      html  css  js  c++  java
  • GdiPlus[51]: 图像(三) 关于呈现


    相关方法:
    IGPGraphics.DrawImage();
    IGPImage.GetThumbnailImage();
    IGPImage.RotateFlip();
    

    用 DrawImage 呈现图像时, 是否指定 Width 和 Height 的区别:



    //如果图像的分辨率与 Graphics 的分辨率不一致, 则指定 Width、Height 是有必要的.
    uses GdiPlus;
    
    procedure TForm1.FormPaint(Sender: TObject);
    var
      Graphics: IGPGraphics;
      Image: IGPImage;
      ix,iy,gx,gy: Single;
    begin
      Image := TGPImage.Create('C:\GdiPlusImg\Shapes.bmp');
      Graphics := TGPGraphics.Create(Handle);
    
      Graphics.DrawImage(Image, 10, 10, Image.Width, Image.Height);
      Graphics.DrawImage(Image, Image.Width + 20, 10);
    
      ix := Image.HorizontalResolution;
      iy := Image.VerticalResolution;
      gx := Graphics.DpiX;
      gy := Graphics.DpiY;
      Text := Format('%.0f:%.0f; %.0f:%.0f', [ix, iy, gx, gy]);
    end;
    

    略缩图:



    uses GdiPlus;
    
    procedure TForm1.FormPaint(Sender: TObject);
    var
      Graphics: IGPGraphics;
      Thumbnail,Image: IGPImage;
    begin
      Image := TGPImage.Create('C:\GdiPlusImg\Apple.gif');
      Thumbnail := Image.GetThumbnailImage(32, 32);
      
      Graphics := TGPGraphics.Create(Handle);
      Graphics.DrawImage(Image, 0, 0, Image.Width, Image.Height);
      Graphics.DrawImage(Thumbnail, Image.Width + 2, 0, Thumbnail.Width, Thumbnail.Height);
    end;
    

    图像旋转:



    uses GdiPlus;
    
    procedure TForm1.FormPaint(Sender: TObject);
    var
      Graphics: IGPGraphics;
      Image,ImageClone: IGPImage;
      i: Integer;
    begin
      Image := TGPImage.Create('C:\GdiPlusImg\Bird.bmp');
      Graphics := TGPGraphics.Create(Handle);
    
      for i := 0 to 7 do
      begin
        ImageClone := Image.Clone;
        ImageClone.RotateFlip(TGPRotateFlipType(i));
        Graphics.DrawImage(ImageClone, 10, 10, Image.Width, Image.Height);
        Graphics.TranslateTransform(Image.Width + 10, 0);
        if i = 3 then
        begin
          Graphics.TranslateTransform(-Graphics.Transform.OffsetX, Image.Height + 10);
        end;
      end;
    end;
    
  • 相关阅读:
    触摸屏多媒体查询展示自主设计系统开发过程
    hashtable数据循环读取的顺序问题
    vs2010英文版打包中文框架出错的解决办法
    Silverlight游戏开发初探(上篇)
    PB之——编码规范
    时间相加 ,使用SQL完成
    PB(POWERBUILDER) 基础介绍
    PB之——流程控制
    PB之——基本数据类型
    PB [Grid风格数据窗口改变线条颜色] 的变通实现方法(也可以成为 带表头的Grid数据窗口)
  • 原文地址:https://www.cnblogs.com/del/p/1634406.html
Copyright © 2011-2022 走看看