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

📄 iopreviews.pas

📁 ·ImageEn 2.3.0 ImageEn一组用于图像处理、查看和分析的Delphi控件。能够保存几种图像格式
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    fParams.FileType := ioTIFF;
  end
  else if (Pagecontrol1.ActivePage = TabSheetGIF1) or (Pagecontrol1.ActivePage = TabSheetGIF2) then
  begin
    // READ GIF PARAMETERS
    fParams.GIF_ImageIndex := GIF_ImageIndex;
    fParams.GIF_XPos := GIF_XPos;
    fParams.GIF_YPos := GIF_YPos;
    fParams.GIF_DelayTime := GIF_DelayTime;
    fParams.GIF_FlagTranspColor := GIF_FlagTranspColor;
    fParams.GIF_TranspColor := GIF_TranspColor;
    fParams.GIF_Interlaced := GIF_Interlaced;
    fParams.GIF_Background := GIF_Background;
    fParams.BitsPerSample := GIF_BitsPerSample;
    fParams.FileType := ioGIF;
  end
  else if PageControl1.ActivePage = TabSheetBMP1 then
  begin
    // READ BMP PARAMETERS
    fParams.BMP_Compression := BMP_Compression;
    case BMP_BitsPerPixel of
      0:
        begin
          fParams.BitsPerSample := 1;
          fParams.SamplesPerPixel := 1;
        end;
      1:
        begin
          fParams.BitsPerSample := 4;
          fParams.SamplesPerPixel := 1;
        end;
      2:
        begin
          fParams.BitsPerSample := 8;
          fParams.SamplesPerPixel := 1;
        end;
      3:
        begin
          fParams.BitsPerSample := 8;
          fParams.SamplesPerPixel := 3;
        end;
      4:
        begin
          fParams.BitsPerSample := 8;
          fParams.SamplesPerPixel := 3;
        end;
    end;
    fParams.FileType := ioBMP;
  end
  else if PageControl1.ActivePage = TabSheetPCX1 then
  begin
    // READ PCX PARAMETERS
    fParams.PCX_Compression := PCX_Compression;
    case PCX_BitsPerPixel of
      0:
        begin
          fParams.BitsPerSample := 1;
          fParams.SamplesPerPixel := 1;
        end;
      1:
        begin
          fParams.BitsPerSample := 4;
          fParams.SamplesPerPixel := 1;
        end;
      2:
        begin
          fParams.BitsPerSample := 8;
          fParams.SamplesPerPixel := 1;
        end;
      3:
        begin
          fParams.BitsPerSample := 8;
          fParams.SamplesPerPixel := 3;
        end;
    end;
    fParams.FileType := ioPCX;
  end
  else if PageControl1.ActivePage = TabSheetPNG1 then
  begin
    {$ifdef IEINCLUDEPNG}
    // READ PNG PARAMETERS
    case PNG_Colors of
      0:
        begin
          fParams.BitsPerSample := 1;
          fParams.SamplesPerPixel := 1;
        end;
      1:
        begin
          fParams.BitsPerSample := 8;
          fParams.SamplesPerPixel := 1;
        end;
      2:
        begin
          fParams.BitsPerSample := 8;
          fParams.SamplesPerPixel := 3;
        end;
    end;
    fParams.PNG_Background := PNG_Background;
    fParams.PNG_Interlaced := PNG_Interlaced;
    fParams.PNG_Filter := TIOPNGFilter(PNG_Filter);
    fParams.PNG_Compression := PNG_Compression;
    fParams.FileType := ioPNG;
    {$endif}
  end
  else if PageControl1.ActivePage = TabSheetTGA1 then
  begin
    // READ TGA PARAMETERS
    case TGA_Colors of
      0:
        begin
          fParams.BitsPerSample := 1;
          fParams.SamplesPerPixel := 1;
        end;
      1:
        begin
          fParams.BitsPerSample := 8;
          fParams.SamplesPerPixel := 1;
        end;
      2:
        begin
          fParams.BitsPerSample := 8;
          fParams.SamplesPerPixel := 3;
        end;
    end;
    fParams.TGA_Background := TGA_Background;
    fParams.TGA_Compressed := TGA_Compressed;
    fParams.TGA_ImageName := TGA_Name;
    fParams.TGA_Descriptor := TGA_Description;
    fParams.FileType := ioTGA;
  end
  else if PageControl1.ActivePage = TabSheetJ20001 then
  begin
    // READ Jpeg2000 PARAMETERS
{$IFDEF IEINCLUDEJPEG2000}
    case J2000_ColorSpace of
      0:
        begin
          fParams.BitsPerSample := 8;
          fParams.SamplesPerPixel := 1;
          fParams.J2000_ColorSpace := ioJ2000_GRAYLEV
        end;
      1:
        begin
          fParams.BitsPerSample := 8;
          fParams.SamplesPerPixel := 3;
          fParams.J2000_ColorSpace := ioJ2000_RGB;
        end;
      2:
        begin
          fParams.BitsPerSample := 8;
          fParams.SamplesPerPixel := 3;
          fParams.J2000_ColorSpace := ioJ2000_YCbCr;
        end;
    end;
    fParams.J2000_Rate := J2000_Rate;
    fParams.FileType := ioJ2K; // or ioJ2P?
{$ENDIF}
  end;
end;

/////////////////////////////////////////////////////////////////////////////////////





/////////////////////////////////////////////////////////////////////////////////////
// return false if the dialog doesn't contains parameters

function TfIOPreviews.SetPreviewParams(xpp: TPreviewParams): boolean;
begin
  pp := xpp;
  if (ppAuto in pp) then
    case fParams.FileType of
      ioTIFF: pp := pp + [ppTIFF];
      ioGIF: pp := pp + [ppGIF];
      ioJPEG: pp := pp + [ppJPEG];
      ioPCX: pp := pp + [ppPCX];
      ioBMP: pp := pp + [ppBMP];
{$IFDEF IEINCLUDEPNG}
      ioPNG: pp := pp + [ppPNG];
{$ENDIF}
      ioTGA: pp := pp + [ppTGA];
{$IFDEF IEINCLUDEJPEG2000}
      ioJ2K: pp := pp + [ppJ2000];
      ioJP2: pp := pp + [ppJ2000];
{$ENDIF}
    end;
  result := not (pp = [ppAuto]);
end;

/////////////////////////////////////////////////////////////////////////////////////
// change PNG

procedure TfIOPreviews.ComboBox10Change(Sender: TObject);
var
  cl, ff, cc: integer;
  ii: boolean;
begin
  if not dochange then
    exit;
  cl := combobox10.itemindex;
  ii := checkbox6.checked;
  ff := combobox11.itemindex;
  cc := combobox12.itemindex;
  if (cl <> PNG_Colors) or (ii <> PNG_Interlaced) or (ff <> PNG_Filter)
    or (cc <> PNG_Compression) then
  begin
    PNG_Colors := cl;
    PNG_Interlaced := ii;
    PNG_Filter := ff;
    PNG_Compression := cc;
    if chkLockPreview.Checked then
    begin
      ApplyAct;
      imageen2.paint;
    end;
  end;
  Button4.Enabled := true;
end;

/////////////////////////////////////////////////////////////////////////////////////
// select PNG-Background color

procedure TfIOPreviews.Panel1Click(Sender: TObject);
var
  fPalDial: TImageEnPaletteDialog;
begin
  if imageen2.IO.Params.ColorMap = nil then
  begin
    // true color
    if ColorDialog1.Execute then
      panel1.color := ColorDialog1.Color;
  end
  else
  begin
    // palette
    fPalDial := TImageEnPaletteDialog.Create(self);
    fPalDial.SetPalette(imageen2.IO.Params.ColorMap^, _GetNumCol(imageen2.IO.Params.BitsPerSample, imageen2.IO.Params.SamplesPerPixel));
    fPalDial.ButtonCancel.Caption := msgCancel;
    if fPalDial.Execute then
      panel1.color := fPalDial.SelCol;
    FreeAndNil(fPalDial);
  end;
  PNG_Background := TCOLOR2TRGB(panel1.color);
  Button4.Enabled := true;
end;

/////////////////////////////////////////////////////////////////////////////////////
// change TGA

procedure TfIOPreviews.ComboBox14Click(Sender: TObject);
var
  cl: integer;
  cc: boolean;
begin
  if not dochange then
    exit;
  cl := combobox14.itemindex;
  cc := checkbox1.checked;
  if (cl <> TGA_Colors) or (cc <> TGA_Compressed) then
  begin
    TGA_Colors := cl;
    TGA_Compressed := cc;
    if chkLockPreview.Checked then
    begin
      ApplyAct;
      imageen2.paint;
    end;
  end;
  TGA_Name := Edit13.text;
  TGA_Description := Edit14.text;
  Button4.Enabled := true;
end;

/////////////////////////////////////////////////////////////////////////////////////
// select TGA-Background

procedure TfIOPreviews.Panel5Click(Sender: TObject);
var
  fPalDial: TImageEnPaletteDialog;
begin
  if imageen2.IO.Params.ColorMap = nil then
  begin
    // true color
    if ColorDialog1.Execute then
      panel5.color := ColorDialog1.Color;
  end
  else
  begin
    // palette
    fPalDial := TImageEnPaletteDialog.Create(self);
    fPalDial.SetPalette(imageen2.IO.Params.ColorMap^, _GetNumCol(imageen2.IO.Params.BitsPerSample, imageen2.IO.Params.SamplesPerPixel));
    fPalDial.ButtonCancel.Caption := msgCancel;
    if fPalDial.Execute then
      panel5.color := fPalDial.SelCol;
    FreeAndNil(fPalDial);
  end;
  TGA_Background := TCOLOR2TRGB(panel5.color);
  Button4.Enabled := true;
end;

// JPEG2000 edit change

procedure TfIOPreviews.Edit15Change(Sender: TObject);
{$IFDEF IEINCLUDEJPEG2000}
var
  q: double;
begin
  if not dochange then
    exit;
  q := strtointdef(edit15.text, 1000) / 1000;
  if (q <> J2000_Rate) then
  begin
    trackbar1.position := trunc(q * 1000);
    trackbar1change(self);
  end;
  Button4.Enabled := true;
end;
{$ELSE}
begin
end;
{$ENDIF}

// JPEG2000 other controls change

procedure TfIOPreviews.TrackBar1Change(Sender: TObject);
begin
{$IFDEF IEINCLUDEJPEG2000}
  if not dochange then
    exit;
  if (round(J2000_Rate * 1000) <> trackbar1.position) or (J2000_ColorSpace <> combobox15.itemindex) then
  begin
    J2000_Rate := trackbar1.position / 1000;
    J2000_ColorSpace := combobox15.itemindex;
    edit15.text := inttostr(round(J2000_Rate * 1000));
    if chkLockPreview.Checked then
    begin
      ApplyAct;
      imageen2.paint;
    end;
    Button4.Enabled := true;
  end;
{$ENDIF}
end;

// change JPEG (edit controls)

procedure TfIOPreviews.Edit22Change(Sender: TObject);
var
  q, w: integer;
begin
  if not dochange then
    exit;
  q := strtointdef(edit22.text, 50);
  w := strtointdef(edit23.text, 0);
  if (q <> JPEG_Quality) or (w <> JPEG_Smooth) then
  begin
    trackbar13.position := q;
    trackbar13change(self);
  end;
  Button4.Enabled := true;
end;

// change JPEG-simplified (edit controls)

procedure TfIOPreviews.Edit16Change(Sender: TObject);
var
  q: integer;
begin
  if not dochange then
    exit;
  q := strtointdef(edit16.text, 50);
  if (q <> JPEG_Quality) then
  begin
    trackbar2.position := q;
    trackbar2change(self);
  end;
  Button4.Enabled := true;
end;

// change JPEG (trackbar13, checkbox1)

procedure TfIOPreviews.TrackBar13Change(Sender: TObject);
var
  w: integer;
begin
  if not dochange then
    exit;
  w := strtointdef(edit23.text, 0);
  if (JPEG_Quality <> trackbar13.position) or
    (JPEG_Photometric <> combobox13.itemindex) or
    (JPEG_DCTMethod <> combobox1.ItemIndex) or
    (JPEG_OptimalHuffman <> checkbox2.checked) or
    (JPEG_Smooth <> w) or
    (JPEG_Progressive <> checkbox3.checked) then
  begin
    JPEG_Quality := trackbar13.position;
    edit22.text := inttostr(JPEG_Quality);
    JPEG_Photometric := combobox13.itemindex;
    JPEG_DCTMethod := combobox1.itemindex;
    JPEG_OptimalHuffman := checkbox2.checked;
    JPEG_Smooth := w;
    JPEG_Progressive := checkbox3.checked;
    if chkLockPreview.Checked then
    begin
      ApplyAct;
      imageen2.paint;
    end;
    Button4.Enabled := true;
  end;
end;

// change JPEG-simplified (trackbar)

procedure TfIOPreviews.TrackBar2Change(Sender: TObject);
begin
  if not dochange then
    exit;
  if (JPEG_Quality <> trackbar2.position) then
  begin
    JPEG_Quality := t

⌨️ 快捷键说明

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