zoukankan      html  css  js  c++  java
  • 关于位图的像素格式


    1、判断位图的像素格式:
    var
      bit: TBitmap;
      pix: TPixelFormat;
      s: string;
    begin
      bit := TBitmap.Create;
      bit.LoadFromFile('c:\temp\test.bmp'); //位图路径
    
      pix := bit.PixelFormat;
      s := '';
      case pix of
        pfDevice: s := 'Device'; {设备支持的像素格式}
        pf1bit:   s := '1bit';
        pf4bit:   s := '4bit';
        pf8bit:   s := '8bit';
        pf15bit:  s := '15bit';
        pf16bit:  s := '16bit';
        pf24bit:  s := '24bit';
        pf32bit:  s := '32bit';
        pfCustom: s := 'Custom';  {其他格式}
      end;
      ShowMessage(s);
    
      bit.Free;
    end;
    

    2、位图的像素格式转换:
    var
      bit: TBitmap;
    begin
      bit := TBitmap.Create;
      bit.LoadFromFile('c:\temp\test.bmp');
      bit.PixelFormat := pf4bit;
      bit.SaveToFile('c:\temp\test2.bmp');
      bit.Free;
    end;
    

    3、按指定的像素格式保存位图:
    var
      bit: TBitmap;
    begin
      bit := Self.GetFormImage;  //把窗体客户区获取为图像, 无须 bit := TBitmap.Create;
      bit.PixelFormat := pf1bit;
      bit.SaveToFile('c:\temp\test.bmp');
      bit.Free; //但要释放
    end;
    
  • 相关阅读:
    蘑菇街
    康拓展开
    CSS学习笔记
    专业名词
    专业名字
    01背包问题
    将bbr功能合入到centos7.3
    How to Identify User&Password of DataBase safely in SQL statement?
    tips for private constructor
    all Key Word of C#
  • 原文地址:https://www.cnblogs.com/del/p/1344912.html
Copyright © 2011-2022 走看看