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

📄 magickgeneral.pas

📁 ImageMagick library of image with Visual C++6
💻 PAS
字号:
unit MagickGeneral;

interface

uses
  Classes, SysUtils;

type

  // Record item in the filetypes table
  TFilterItemType = record
    Ext: string;  // Extension
    RW: string;   // Read and write support.. 'R' = Read, 'W' = Write, 'RW' = Both
    Name: string; // Filetype short description
  end;

const

  cFilterItemCount = 102;

  // RW = Read and Write support, "R" = Read, "W" = Write
  cFilterItems: array[0..cFilterItemCount - 1] of TFilterItemType =
  ( (Ext: 'ART';  RW: 'R';  Name: 'PFS: 1st Publisher'),
    (Ext: 'AVI';  RW: 'R';  Name: 'Microsoft Audio/Visual Interleaved'),
    (Ext: 'AVS';  RW: 'RW'; Name: 'AVS X image'),
    (Ext: 'BMP';  RW: 'RW'; Name: 'Microsoft Windows bitmap'),
    (Ext: 'CGM';  RW: 'R';  Name: 'Computer Graphics Metafile'),
    (Ext: 'CMYK'; RW: 'RW'; Name: 'Raw cyan, magenta, yellow, and black samples'),
    (Ext: 'CUT';  RW: 'R';  Name: 'DR Halo'),
    (Ext: 'DCM';  RW: 'R';  Name: 'Digital Imaging and Communications in Medicine (DICOM) image'),
    (Ext: 'DCX';  RW: 'RW'; Name: 'ZSoft IBM PC multi-page Paintbrush image'),
    (Ext: 'DIB';  RW: 'RW'; Name: 'Microsoft Windows Device Independent Bitmap'),
    (Ext: 'DPX';  RW: 'RW'; Name: 'Digital Moving Picture Exchange'),
    (Ext: 'EMF';  RW: 'R';  Name: 'Microsoft Enhanced Metafile (32-bit)'),
    (Ext: 'EPDF'; RW: 'RW'; Name: 'Encapsulated Portable Document Format'),
    (Ext: 'EPI';  RW: 'RW'; Name: 'Adobe Encapsulated PostScript Interchange format'),
    (Ext: 'EPS';  RW: 'RW'; Name: 'Adobe Encapsulated PostScript'),
    (Ext: 'EPS2'; RW: 'W';  Name: 'Adobe Level II Encapsulated PostScript'),
    (Ext: 'EPS3'; RW: 'W';  Name: 'Adobe Level III Encapsulated PostScript'),
    (Ext: 'EPSF'; RW: 'RW'; Name: 'Adobe Encapsulated PostScript'),
    (Ext: 'EPSI'; RW: 'RW'; Name: 'Adobe Encapsulated PostScript Interchange format'),
    (Ext: 'EPT';  RW: 'RW'; Name: 'Adobe Encapsulated PostScript Interchange format with TIFF preview'),
    (Ext: 'FAX';  RW: 'RW'; Name: 'Group 3 TIFF'),
    (Ext: 'FIG';  RW: 'R';  Name: 'FIG graphics format'),
    (Ext: 'FITS'; RW: 'RW'; Name: 'Flexible Image Transport System'),
    (Ext: 'FPX';  RW: 'RW'; Name: 'FlashPix Format'),
    (Ext: 'GIF';  RW: 'RW'; Name: 'CompuServe Graphics Interchange Format'),
    (Ext: 'GPLT'; RW: 'R';  Name: 'Gnuplot plot files'),
    (Ext: 'GRAY'; RW: 'RW'; Name: 'Raw gray samples'),
    (Ext: 'HPGL'; RW: 'R';  Name: 'HP-GL plotter language'),
    (Ext: 'HTML'; RW: 'RW'; Name: 'Hypertext Markup Language'),
    (Ext: 'HTM';  RW: 'RW'; Name: 'Hypertext Markup Language'),
    (Ext: 'ICO';  RW: 'R';  Name: 'Microsoft icon'),
    (Ext: 'JBIG'; RW: 'RW'; Name: 'Joint Bi-level Image experts Group file interchange format'),
    (Ext: 'JNG';  RW: 'RW'; Name: 'Multiple-image Network Graphics'),
    (Ext: 'JP2';  RW: 'RW'; Name: 'JPEG-2000 JP2 File Format Syntax'),
    (Ext: 'JPC';  RW: 'RW'; Name: 'JPEG-2000 Code Stream Syntax'),
    (Ext: 'JPEG'; RW: 'RW'; Name: 'Joint Photographic Experts Group JFIF format'),
    (Ext: 'JPG';  RW: 'RW'; Name: 'Joint Photographic Experts Group JFIF format'),
    (Ext: 'MAN';  RW: 'R';  Name: 'Unix reference manual pages'),
    (Ext: 'MAT';  RW: 'R';  Name: 'MATLAB image format'),
    (Ext: 'MIFF'; RW: 'RW'; Name: 'Magick image file format'),
    (Ext: 'MONO'; RW: 'RW'; Name: 'Bi-level bitmap in least-significant-byte first order'),
    (Ext: 'MNG';  RW: 'RW'; Name: 'JPEG Network Graphics'),
    (Ext: 'MPEG'; RW: 'RW'; Name: 'Motion Picture Experts Group file interchange format (version 1)'),
    (Ext: 'MPG';  RW: 'RW'; Name: 'Motion Picture Experts Group file interchange format (version 1)'),
    (Ext: 'M2V';  RW: 'RW'; Name: 'Motion Picture Experts Group file interchange format (version 2)'),
    (Ext: 'MPC';  RW: 'RW'; Name: 'Magick Persistent Cache image file format'),
    (Ext: 'MSL';  RW: 'RW'; Name: 'Magick Scripting Language'),
    (Ext: 'MTV';  RW: 'RW'; Name: 'MTV Raytracing image format'),
    (Ext: 'MVG';  RW: 'RW'; Name: 'Magick Vector Graphics'),
    (Ext: 'OTB';  RW: 'RW'; Name: 'On-the-air Bitmap'),
    (Ext: 'P7';   RW: 'RW'; Name: 'Xv Visual Schnauzer thumbnail format'),
    (Ext: 'PALM'; RW: 'RW'; Name: 'Palm pixmap'),
    (Ext: 'PBM';  RW: 'RW'; Name: 'Portable bitmap format (black and white)'),
    (Ext: 'PCD';  RW: 'RW'; Name: 'Photo CD'),
    (Ext: 'PCDS'; RW: 'RW'; Name: 'Photo CD'),
    (Ext: 'PCL';  RW: 'W';  Name: 'HP Page Control Language'),
    (Ext: 'PCX';  RW: 'RW'; Name: 'ZSoft IBM PC Paintbrush file'),
    (Ext: 'PDB';  RW: 'RW'; Name: 'Palm Database ImageViewer Format'),
    (Ext: 'PDF';  RW: 'RW'; Name: 'Portable Document Format'),
    (Ext: 'PFA';  RW: 'R';  Name: 'Postscript Type 1 font (ASCII)'),
    (Ext: 'PFB';  RW: 'R';  Name: 'Postscript Type 1 font (binary)'),
    (Ext: 'PGM';  RW: 'RW'; Name: 'Portable graymap format (gray scale)'),
    (Ext: 'PICON';RW: 'RW'; Name: 'Personal Icon'),
    (Ext: 'PICT'; RW: 'RW'; Name: 'Apple Macintosh QuickDraw/PICT file'),
    (Ext: 'PIX';  RW: 'R';  Name: 'Alias/Wavefront RLE image format'),
    (Ext: 'PNG';  RW: 'RW'; Name: 'Portable Network Graphics'),
    (Ext: 'PNM';  RW: 'RW'; Name: 'Portable anymap'),
    (Ext: 'PPM';  RW: 'RW'; Name: 'Portable pixmap format (color)'),
    (Ext: 'PS';   RW: 'RW'; Name: 'Adobe PostScript file'), // 69
    (Ext: 'PS2';  RW: 'RW'; Name: 'Adobe Level II PostScript file'),
    (Ext: 'PS3';  RW: 'RW'; Name: 'Adobe Level III PostScript file'),
    (Ext: 'PSD';  RW: 'RW'; Name: 'Adobe Photoshop bitmap file'),
    (Ext: 'PTIF'; RW: 'RW'; Name: 'Pyramid encoded TIFF'),
    (Ext: 'PWP';  RW: 'R';  Name: 'Seattle File Works multi-image file'),
    (Ext: 'RAD';  RW: 'R';  Name: 'Radiance image file'),
    (Ext: 'RGB';  RW: 'RW'; Name: 'Raw red, green, and blue samples'),
    (Ext: 'RGBA'; RW: 'RW'; Name: 'Raw red, green, blue, and matte samples'),
    (Ext: 'RLA';  RW: 'R';  Name: 'Alias/Wavefront image file'),
    (Ext: 'RLE';  RW: 'R';  Name: 'Utah Run length encoded image file'),
    (Ext: 'SCT';  RW: 'R';  Name: 'Scitex Continuous Tone Picture'),
    (Ext: 'SFW';  RW: 'R';  Name: 'Seattle File Works image'),
    (Ext: 'SGI';  RW: 'RW'; Name: 'Irix RGB image'),
    (Ext: 'SHTML';RW: 'W';  Name: 'Hypertext Markup Language client-side image map'),
    (Ext: 'SUN';  RW: 'RW'; Name: 'SUN Rasterfile'),
    (Ext: 'SVG';  RW: 'RW'; Name: 'Scalable Vector Graphics'),
    (Ext: 'TGA';  RW: 'RW'; Name: 'Truevision Targa image'),
    (Ext: 'TIFF'; RW: 'RW'; Name: 'Tagged Image File Format'),
    (Ext: 'TIF';  RW: 'RW'; Name: 'Tagged Image File Format'),
    (Ext: 'TIM';  RW: 'R';  Name: 'PSX TIM file'),
    (Ext: 'TTF';  RW: 'R';  Name: 'TrueType font file'),
    (Ext: 'TXT';  RW: 'RW'; Name: 'Raw text file'),
    (Ext: 'UIL';  RW: 'W';  Name: 'X-Motif UIL table'),
    (Ext: 'UYVY'; RW: 'RW'; Name: 'Interleaved YUV raw image'),
    (Ext: 'VICAR';RW: 'RW'; Name: 'VICAR rasterfile format'),
    (Ext: 'VIFF'; RW: 'RW'; Name: 'Khoros Visualization Image File Format'),
    (Ext: 'WBMP'; RW: 'RW'; Name: 'Wireless bitmap'),
    (Ext: 'WMF';  RW: 'RW'; Name: 'Windows Metafile'),
    (Ext: 'WPG';  RW: 'R';  Name: 'Word Perfect Graphics File'),
    (Ext: 'XBM';  RW: 'RW'; Name: 'X Windows system bitmap, black and white only'),
    (Ext: 'XCF';  RW: 'R';  Name: 'GIMP image'),
    (Ext: 'XPM';  RW: 'RW'; Name: 'X Windows system pixmap'),
    (Ext: 'YUV';  RW: 'RW'; Name: 'CCIR 601 4:1:1')
  );

// Create a filetype filter for open/save dialog. Use Func = 'R' for Open and
// Func = 'W' for Save dialog
function CreateDialogFilter(Func: Char): string;

// Get the file extension of item at Index in filter
function GetSaveFilterExtension(Index: integer): string;

implementation

function CreateDialogFilter(Func: Char): string;
// Create a filetype filter for open/save dialog
var
  i: integer;
  AFilter: TStringList;
  AExt: string;
begin
  AFilter := TStringList.Create;

  if Pos('R', Func) > 0 then begin
    for i := 0 to cFilterItemCount - 1 do
      if Pos(Func, cFilterItems[i].RW) > 0 then
        AExt := AExt + Format('*.%s;', [LowerCase(cFilterItems[i].Ext)]);
    AFilter.Add('ImageMagick Files|' + AExt);
    AFilter.Add('All Files (*.*)|*.*');
  end;

  for i := 0 to cFilterItemCount - 1 do begin
    if Pos(Func, cFilterItems[i].RW) > 0 then begin
      AExt := Format('*.%s', [LowerCase(cFilterItems[i].Ext)]);
      AFilter.Add(Format('(%s) %s|%s', [AExt, cFilterItems[i].Name, AExt]));
    end;
  end;

  if AFilter.Count > 0 then
    Result := AFilter[0];
  for i := 1 to AFilter.Count - 1 do
    Result := Result + '|' + AFilter[i];
end;

function GetSaveFilterExtension(Index: integer): string;
var
  i: integer;
begin
  for i := 0 to cFilterItemCount - 1 do
    if Pos('W', cFilterItems[i].RW) > 0 then begin
      if Index = 0 then begin
        // Chakka.. we have the right one
        Result := LowerCase(cFilterItems[i].Ext);
        break;
      end else
        dec(Index);
    end;
end;

end.

⌨️ 快捷键说明

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