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

📄 previews.pas

📁 ·ImageEn 2.3.0 ImageEn一组用于图像处理、查看和分析的Delphi控件。能够保存几种图像格式
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  begin
    imageen2.Proc.undo;
    ApplyAct(imageen2);
    imageen2.paint;
  end;
end;

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

procedure TfPreviews.RulerBox2RulerPosChange(Sender: TObject;
  Grip: Integer);
begin
  if not dochange then
    exit;
  // Aggiorna labels
  if RulerBox2.GripsPos[0] > RulerBox2.GripsPos[1] then
    if Grip = 0 then
      RulerBox2[1] := RulerBox2[0]
    else
      RulerBox2[0] := RulerBox2[1];
  if Grip = 0 then
    Label20.Caption := inttostr(trunc(RulerBox2.GripsPos[0]))
  else if Grip = 1 then
    Label21.Caption := inttostr(trunc(RulerBox2.GripsPos[1]));
  //
  if (CheckListBox1.Checked[0]) or (CheckListBox1.Checked[3]) then
  begin
    // RED
    EDownLimit.r := trunc(RulerBox2.GripsPos[0]);
    EUpLimit.r := trunc(RulerBox2.GripsPos[1]);
  end;
  if (CheckListBox1.Checked[1]) or (CheckListBox1.Checked[3]) then
  begin
    // GREEN
    EDownLimit.g := trunc(RulerBox2.GripsPos[0]);
    EUpLimit.g := trunc(RulerBox2.GripsPos[1]);
  end;
  if (CheckListBox1.Checked[2]) or (CheckListBox1.Checked[3]) then
  begin
    // BLUE
    EDownLimit.b := trunc(RulerBox2.GripsPos[0]);
    EUpLimit.b := trunc(RulerBox2.GripsPos[1]);
  end;
  if chkLockPreview.checked then
  begin
    imageen2.Proc.undo;
    ApplyAct(imageen2);
    imageen2.paint;
  end;
end;

/////////////////////////////////////////////////////////////////////////////////////
// BUTTON - AUTOEQUALIZE

procedure TfPreviews.SpeedButton3Click(Sender: TObject);
begin
  if chkLockPreview.checked then
  begin
    imageen2.Proc.undo;
    ApplyAct(imageen2);
    imageen2.paint;
  end;
end;

// change contrast (trackbar1) or brightness (trackbar12)

procedure TfPreviews.TrackBar1Change(Sender: TObject);
begin
  if not dochange then
    exit;
  if (Contrast <> trackbar1.position) or (Brightness <> trackbar12.position) then
  begin
    Contrast := trackbar1.position;
    edit1.text := inttostr(Contrast);
    Brightness := trackbar12.position;
    edit21.text := inttostr(Brightness);
    if chkLockPreview.checked then
    begin
      imageen2.Proc.undo;
      ApplyAct(imageen2);
      imageen2.paint;
    end;
  end;
end;

// change contrast (edit1) or brightness (edit21)

procedure TfPreviews.Edit1Change(Sender: TObject);
var
  v, b: integer;
begin
  if not dochange then
    exit;
  v := strtointdef(edit1.text, 0);
  b := strtointdef(edit21.text, 0);
  if (v <> Contrast) or (b <> Brightness) then
  begin
    trackbar1.position := v;
    trackbar12.position := b;
    trackbar1change(self);
  end;
end;

/////////////////////////////////////////////////////////////////////////////////////
// Set language

procedure TfPreviews.SetLanguage(l: TMsgLanguage);
begin
  Caption := iemsg(IEMSG_PREVIEW, l);
  Label1.Caption := iemsg(IEMSG_SOURCE, l) + ':';
  Label2.Caption := iemsg(IEMSG_RESULT, l) + ':';
  Button1.Caption := iemsg(IEMSG_OK, l);
  Button2.Caption := iemsg(IEMSG_CANCEL, l);
  chkLockPreview.Caption := iemsg(IEMSG_LOCKPREVIEW, l);
  chkLockPreview.Hint := iemsg(IEMSG_LOCKPREVIEWHINT, l);
  Button6.hint := iemsg(IEMSG_COPYRESULTTOSOURCE, l);
  button3.caption := iemsg(IEMSG_PREVIEW, l);
  // Contrast
  TabSheet1.Caption := iemsg(IEMSG_CONTRAST, l);
  Label3.Caption := iemsg(IEMSG_CONTRAST, l);
  Label22.Caption := iemsg(IEMSG_BRIGHTNESS, l) + ':';
  // HSV
  TabSheet5.Caption := iemsg(IEMSG_HSV,l);
  // HSB
  Label10.Caption := iemsg(IEMSG_HUE, l) + ' (H):';
  Label11.Caption := iemsg(IEMSG_SATURATION, l) + ' (S):';
  Label12.Caption := iemsg(IEMSG_VALUE, l) + ' (V):';
  Label13.Caption := iemsg(IEMSG_BASECOLOR, l) + ':';
  Label14.Caption := iemsg(IEMSG_NEWCOLOR, l) + ':';
  // HSL
  TabSheet2.CAption := iemsg(IEMSG_HSL,l);
  Label4.Caption := iemsg(IEMSG_HUE, l) + ' (H):';
  Label5.Caption := iemsg(IEMSG_SATURATION, l) + ' (S):';
  Label6.Caption := iemsg(IEMSG_LUMINOSITY, l) + ' (L):';
  // RGB
  TabSheet3.Caption := iemsg(IEMSG_RGB,l);
  Label7.Caption := iemsg(IEMSG_RED, l) + ' (R):';
  Label8.Caption := iemsg(IEMSG_GREEN, l) + ' (G):';
  Label9.Caption := iemsg(IEMSG_BLUE, l) + ' (B):';
  // Filters
  TabSheet4.Caption := iemsg(IEMSG_USERFILTER, l);
  GroupBox1.Caption := ' ' + iemsg(IEMSG_FILTERVALUES, l) + ' ';
  GroupBox3.Caption := ' ' + iemsg(IEMSG_PRESETS, l) + ' ';
  Label15.Caption := iemsg(IEMSG_DIVISOR, l);
  Button4.Caption := iemsg(IEMSG_LOAD, l);
  Button5.Caption := iemsg(IEMSG_SAVE, l);
  SaveDialog1.Title := iemsg(IEMSG_SAVEFILTER, l);
  OpenDialog1.Title := iemsg(IEMSG_LOADFILTER, l);
  // Hist equalization
  TabSheet6.Caption := iemsg(IEMSG_EQUALIZATION, l);
  Label19.Caption := iemsg(IEMSG_EQUALIZATION, l);
  Label18.Caption := iemsg(IEMSG_THRESHOLD, l);
  SpeedButton3.Caption := iemsg(IEMSG_EQUALIZE, l);
  GroupBox4.Caption := ' ' + iemsg(IEMSG_HISTOGRAM, l) + ' ';
  // we have to clear before add, this avoid memory leak on some Delphi versions
  CheckListBox1.Items.Clear;
  CheckListBox1.Items.add(iemsg(IEMSG_RED, l));
  CheckListBox1.Items.add(iemsg(IEMSG_GREEN, l));
  CheckListBox1.Items.add(iemsg(IEMSG_BLUE, l));
  CheckListBox1.Items.add(iemsg(IEMSG_GRAY, l));
  // Bump map
  TabSheet7.Caption := iemsg(IEMSG_BUMPMAP, l);
  GroupBox2.Caption := ' ' + iemsg(IEMSG_LIGHT, l) + ' ';
  label27.Caption := iemsg(IEMSG_LEFT, l) + ':';
  label28.caption := iemsg(IEMSG_TOP, l) + ':';
  label23.caption := iemsg(IEMSG_WIDTH, l) + ':';
  label24.caption := iemsg(IEMSG_HEIGHT, l) + ':';
  label26.caption := iemsg(IEMSG_COLOR, l) + ':';
  label25.caption := iemsg(IEMSG_SOURCEIMAGEQUANTITY, l) + ' (%):';
  // Lens
  TabSheet8.Caption := iemsg(IEMSG_LENS, l);
  GroupBox5.Caption := ' ' + iemsg(IEMSG_LENS, l) + ' ';
  label32.Caption := iemsg(IEMSG_LEFT, l) + ':';
  label33.caption := iemsg(IEMSG_TOP, l) + ':';
  label29.caption := iemsg(IEMSG_WIDTH, l) + ':';
  label30.caption := iemsg(IEMSG_HEIGHT, l) + ':';
  label31.caption := iemsg(IEMSG_REFRACTION, l) + ':';
  // Wave
  TabSheet9.Caption := iemsg(IEMSG_WAVE, l);
  GroupBox6.Caption := ' ' + iemsg(IEMSG_WAVE, l) + ' ';
  label34.caption := iemsg(IEMSG_AMPLITUDE, l);
  label35.caption := iemsg(IEMSG_WAVELENGTH, l);
  label36.caption := iemsg(IEMSG_PHASE, l);
  checkbox2.Caption := iemsg(IEMSG_REFLECTIVE, l);
  // Morph filter
  TabSheet10.Caption := iemsg(IEMSG_MORPHFILTER, l);
  GroupBox7.Caption := ' ' + iemsg(IEMSG_MORPHFILTER, l) + ' ';
  Label37.Caption := iemsg(IEMSG_FILTER, l) + ':';
  Label38.Caption := iemsg(IEMSG_WINDOWSIZE, l) + ':';
  ListBox2.Clear;
  ListBox2.Items.Add(iemsg(IEMSG_MAXIMUM, l));
  ListBox2.Items.Add(iemsg(IEMSG_MINIMUM, l));
  ListBox2.Items.Add(iemsg(IEMSG_OPEN, l));
  ListBox2.Items.Add(iemsg(IEMSG_CLOSE, l));
  // Rotate
  TabSheet11.Caption := iemsg(IEMSG_ROTATE, l);
  LabelRotate.Caption := iemsg(IEMSG_ROTATE, l) + ':';
  Label46.Caption := ' '+iemsg(IEMSG_FLIP, l)+' ';
  CheckBox3.Caption := iemsg(IEMSG_FLIPHOR, l);
  CheckBox4.Caption := iemsg(IEMSG_FLIPVER, l);
  // FFT
  TabSheet12.Caption :=  iemsg(IEMSG_FFT,l);
  GroupBox8.Caption := ' ' + iemsg(IEMSG_SELECTTHEREGIONTOCLEAR, l) + ' ';
  Clear.Caption := iemsg(IEMSG_CLEAR, l);
  Button7.Caption := iemsg(IEMSG_RESET, l);
  CheckBox1.Caption := iemsg(IEMSG_GRAYSCALE, l);
  // gamma
  GroupBox9.Caption := ' '+iemsg(IEMSG_CHANNELS,l)+' ';
  tabGamma.Caption := iemsg(IEMSG_GAMMACORRECTION,l);
  label39.caption := iemsg(IEMSG_GAMMACORRECTION, l);
  cbxGamma.Items[0] := iemsg(IEMSG_RED, l);
  cbxGamma.Items[1] := iemsg(IEMSG_GREEN, l);
  cbxGamma.Items[2] := iemsg(IEMSG_BLUE, l);
  // sharpen
  TabSheet14.Caption := iemsg(IEMSG_SHARPEN,l);
  Label44.Caption := iemsg(IEMSG_AMPLITUDE, l);
  Label45.Caption := iemsg(IEMSG_WINDOWSIZE, l);
end;

/////////////////////////////////////////////////////////////////////////////////////
// preview

procedure TfPreviews.Button3Click(Sender: TObject);
begin
  imageen2.Proc.undo;
  ApplyAct(imageen2);
  imageen2.paint;
end;

/////////////////////////////////////////////////////////////////////////////////////
// preview-lock

procedure TfPreviews.SpeedButton1Click(Sender: TObject);
begin
  if chkLockPreview.checked then
  begin
    imageen2.Proc.undo;
    ApplyAct(imageen2);
    imageen2.paint;
  end;
  button3.enabled := not chkLockPreview.checked; // enable/disable preview button
  button3.visible := not chkLockPreview.checked; // enable/disable preview button
end;

/////////////////////////////////////////////////////////////////////////////////////
// Variazione HSV (trackbar9-10-11)

procedure TfPreviews.TrackBar9Change(Sender: TObject);
begin
  if not dochange then
    exit;
  if (bHue <> trackbar9.position) or (bSat <> trackbar10.position) or (bVal <> trackbar11.position) then
  begin
    bHue := trackbar9.position;
    bSat := trackbar10.position;
    bVal := trackbar11.position;
    edit19.text := inttostr(bHue);
    edit18.text := inttostr(bSat);
    edit17.text := inttostr(bVal);
    if chkLockPreview.checked then
    begin
      imageen2.Proc.undo;
      ApplyAct(imageen2);
      imageen2.paint;
    end;
  end;
end;

/////////////////////////////////////////////////////////////////////////////////////
// Variazione HSV (edit19-18-17)

procedure TfPreviews.Edit19Change(Sender: TObject);
var
  h, s, v: integer;
begin
  if not dochange then
    exit;
  h := strtointdef(edit19.text, 0);
  s := strtointdef(edit18.text, 0);
  v := strtointdef(edit17.text, 0);
  if (bHue <> h) or (bSat <> s) or (bVal <> v) then
  begin
    trackbar9.position := h;
    trackbar10.position := s;
    trackbar11.position := v;
    trackbar2change(self);
  end;
end;

/////////////////////////////////////////////////////////////////////////////////////
// Cambia HSVBox
// 3=org   1=dest

procedure TfPreviews.HSVBox3Change(Sender: TObject);
begin
  trackbar9.Position := HSVBox1.Hue - HSVBox3.Hue;
  trackbar10.Position := HSVBox1.Sat - HSVBox3.Sat;
  trackbar11.Position := HSVBox1.Val - HSVBox3.Val;
  TrackBar9Change(Self);
end;

/////////////////////////////////////////////////////////////////////////////////////
// Cambia BumpLeft, BumpTop, BumpWidth, BumpHeight (edit22-25)

procedure TfPreviews.Edit22Change(Sender: TObject);
var
  bleft, btop, bwidth, bheight: integer;
  bsrc: integer;
begin
  if not dochange then
    exit;
  bleft := strtointdef(edit22.text, 0);
  btop := strtointdef(edit23.text, 0);
  bwidth := strtointdef(edit24.text, 0);
  bheight := strtointdef(edit25.text, 0);
  bsrc := strtointdef(edit26.text, 0);
  if (bleft <> BumpLeft) or (btop <> BumpTop) or (bwidth <> BumpWidth) or (bheight <> BumpHeight) or
    (bsrc <> BumpSrc) then
  begin
    BumpLeft := bleft;
    BumpTop := btop;
    BumpWidth := bwidth;
    BumpHeight := bheight;
    BumpSrc := bsrc;
    if chkLockPreview.checked then
    begin
      imageen2.Proc.undo;
      ApplyAct(imageen2);
      imageen2.paint;
    end;
  end;
end;

/////////////////////////////////////////////////////////////////////////////////////
// Cambia BumpCol (HSVBox2)

procedure TfPreviews.HSVBox2Change(Sender: TObject);
begin
  if not dochange then
    exit;
  BumpCol := CreateRGB(HSVBox2.Red, HSVBox2.Green, HSVBox2.Blue);
  if chkLockPreview.checked then
  begin
    imageen2.Proc.undo;
    ApplyAct(imageen2);
    imageen2.paint;
  end;
end;

/////////////////////////////////////////////////////////////////////////////////////
// click sull'immagine, preleva colore se siamo in variazione HSV
// sposta luce se siamo in BumpMap
// sposta lente se siamo in Lens

procedure TfPreviews.ImageEn2MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  h, s, v: integer;
  c: TColor;
  rgb: TRGB;
begin
  if (PageControl1.ActivePage = TabSheet5) and (Button = mbLeft) then
  begin
    // HSV
    c := imageen2.GetCanvas.pixels[x, y];
    rgb := TColor2TRGB(c);
    RGB2HSV(rgb, h, s, v);
    HSVBox3.Hue := h;
    HSVBox3.Sat := s;
    HSVBox3.Val := v;
  end;
  if PageControl1.ActivePage = TabSheet7 then
  begin
    // Bump map
    BumpLeft := trunc((X - ImageEn1.OffSetX) * (100 / ImageEn1.Zoom)) + ImageEn1.ViewX;
    BumpTop := trunc((Y - ImageEn1.OffSetY) * (100 / ImageEn1.zoom)) + ImageEn1.ViewY;
    dochange := false;
    edit22.text := inttostr(BumpLeft);
    edit23.text := inttostr(BumpTop);
    dochange := true;
    if chkLockPreview.checked then
    begin
      imageen2.Proc.undo;
      ApplyAct(imageen2);
      imageen2.paint;
    end;
  end;
  if PageControl1.ActivePage = TabSheet8 then
  begin
    // Lens
    LensLeft := trunc((X - ImageEn1.OffSetX) * (100 / ImageEn1.Zoom)) + ImageEn1.ViewX;
    LensTop := trunc((Y - ImageEn1.OffSetY) * (100 / ImageEn1.zoom)) + ImageEn1.ViewY;
    dochange := false;
    edit27.text := inttostr(LensLeft);
    edit28.text := inttostr(LensTop);
    dochange := true;
    if chkLockPreview.checked then
    begin
      imageen2.Proc.undo;
      ApplyAct(imageen2);
      imageen2.paint;
    end;
  end;
end;

/////////////////////////////////////////////////////////////////////////////////////
// Cambio controlli Lens

procedure TfPreviews.Edit27Change(Sender: TObject);
var
  lleft, ltop, lwidth, lheight: integer;
  lref: double;
begin
  if not dochange then
    exit;
  lleft := strtointdef(edit27.text, 0);
  ltop := strtointdef(edit28.text, 0);
  lwidth := strtointdef(edit29.text, 0);
  lheight := strtointdef(edit30.text, 0);

⌨️ 快捷键说明

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