谁有类似Photoshop渐编辑变器的色彩调整控件(50分)

  • 主题发起人 主题发起人 YFLK
  • 开始时间 开始时间
Y

YFLK

Unregistered / Unconfirmed
GUEST, unregistred user!
[:)]如题!请大家帮忙!
 
http://www.soft-gems.net/ColorPicker.php
试试这个
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, ComCtrls;

type
TForm1 = class(TForm)
OrigImage: TImage;
DestImage: TImage;
RedTrackBar: TTrackBar;
Label3: TLabel;
GreenTrackBar: TTrackBar;
Label5: TLabel;
BlueTrackBar: TTrackBar;
Label7: TLabel;
procedure FormCreate(Sender: TObject);
procedure TrackBarChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

const
MaxPixelCount = 32768;

type
pRGBArray = ^TRGBArray;
TRGBArray = ARRAY[0..MaxPixelCount-1] OF TRGBTriple;

function Min(a, b: integer): integer;
function Max(a, b: integer): integer;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
OrigImage.Picture.LoadFromFile('DELPHI6.BMP');
DestImage.Picture.LoadFromFile('DELPHI6.BMP');

OrigImage.Picture.Bitmap.PixelFormat := pf24bit;
DestImage.Picture.Bitmap.PixelFormat := pf24bit;
end;

procedure TForm1.TrackBarChange(Sender: TObject);
var i, j, RedValue, GreenValue, BlueValue: integer;
OrigRow, DestRow: pRGBArray;
begin
// get brightness increment value
RedValue := RedTrackBar.Position;
GreenValue := GreenTrackBar.Position;
BlueValue := BlueTrackBar.Position;

// for each row of pixels
for i := 0 to OrigImage.Picture.Height - 1 do
begin
OrigRow := OrigImage.Picture.Bitmap.ScanLine;
DestRow := DestImage.Picture.Bitmap.ScanLine;

// for each pixel in row
for j := 0 to OrigImage.Picture.Width - 1 do
begin
// add brightness value to pixel's RGB values
if RedValue > 0 then
DestRow[j].rgbtRed := Min(255, OrigRow[j].rgbtRed + RedValue)
else
DestRow[j].rgbtRed := Max(0, OrigRow[j].rgbtRed + RedValue);

if GreenValue > 0 then
DestRow[j].rgbtGreen := Min(255, OrigRow[j].rgbtGreen + GreenValue)
else
DestRow[j].rgbtGreen := Max(0, OrigRow[j].rgbtGreen + GreenValue);

if BlueValue > 0 then
DestRow[j].rgbtBlue := Min(255, OrigRow[j].rgbtBlue + BlueValue)
else
DestRow[j].rgbtBlue := Max(0, OrigRow[j].rgbtBlue + BlueValue);

end;
end;

DestImage.Repaint;
end;

function Min(a, b: integer): integer;
begin
if a < b then result := a
else result := b;
end;

function Max(a, b: integer): integer;
begin
if a > b then result := a
else result := b;
end;

end.
 
谢谢chaofan201!
虽然你的代码与我想要的效果不一致,但我的感谢是忠心的!

可能我的问题大家不太明白,
在Photoshop的图层样式中有一个渐编辑变器的色彩调整控件,通过它可以设计出彩色条纹图案.(没办法帖图,只能用文字描述)
 

Similar threads

回复
0
查看
1K
不得闲
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部