2009年下半年全国计算机等级考试你准备好了没?考计算机等级考试的朋友,2009年下半年全国计算机等级考试时间是2009年9月19日至23日。更多优质资料尽在
考试大论坛 考试大在线题库 原来见过一个png图像换肤处理的文章,但其中颜色处理上有些问题,特作优化修正处理,本是回复群友的问题的,所以用的是bmp图片,png图片处理原理是一样的。代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
ColorBox1: TColorBox;
procedure btn1Click(Sender: TObject);
procedure ColorBox1Select(Sender: TObject);
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
var
i, j: Integer;
Row: pRGBTriple;
Rgb : Longint;
RGB_R,RGB_G,RGB_B:Byte;
Gray: Byte;
bmp:TBitmap;
begin
RGB := ColorToRGB(ColorBox1.Selected);
RGB_R := GetRValue(RGB);
RGB_G := GetGValue(RGB);
RGB_B := GetBValue(RGB);
bmp:=TBitmap.Create;
try
bmp.LoadFromFile('E:/Documents and Settings/siow/桌面/main.bmp');
for i := 0 to bmp.Height - 1 do
begin
Row := bmp.Scanline[i];
for j := 0 to bmp.Width - 1 do
begin
//灰度化
Gray:=Trunc((Row^.rgbtRed*306+Row^.rgbtGreen*601+Row^.rgbtBlue*117+512) shr 10);
Row^.rgbtRed := Round(255 - (255 - Gray)* (255-RGB_R)/ 255);
Row^.rgbtGreen := Round(255 - (255 - Gray)* (255-RGB_G)/ 255);
Row^.rgbtBlue := Round(255 - (255 - Gray)* (255-RGB_B)/ 255);
Inc(Row);
end;
end;
self.Canvas.StretchDraw(bmp.Canvas.ClipRect,bmp);
finally
bmp.Free;
end;
end;
procedure TForm1.ColorBox1Select(Sender: TObject);
begin
btn1Click(nil);
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
btn1Click(nil);
end;
end.
特别推荐:
2009年9月全国计算机等级考试时间及科目预告
2009年上半年全国计算机等级考试参考答案请进入计算机考试论坛
2009年全国计算机等级考试报名信息汇总
2009年NCRE考试有新变化
2009年全国计算机等级考试大纲
2009年上半年全国计算机二级考试试题及答案
2009年上半年全国计算机等级考试试题答案汇总