procedure TForm1.Button1Click(Sender: TObject); var bmp:Tbitmap; i,j:integer; begin bmp:=Tbitmap.Create; bmp.Width:=100; bmp.Height:=100; for i:=0 to bmp.Width-1 do for j:=0 to bmp.Height-1 do bmp.Canvas.Pixels[i,j]:=clred; bmp.SaveToFile('d:\tmp.bmp'); bmp.free; end;
我就郁闷了 怎么还是不行呢'?在帮忙看看... var i,j:integer; bmp:tbitmap; begin if colordialog1.Execute then begin inic.WriteString('图层属性',t+'透空的颜色值',colortostring(colordialog1.Color)); bmp:=Tbitmap.Create; bmp.Width:=13; bmp.Height:=12; for i:=0 to bmp.Width-1 do for j:=0 to bmp.Height-1 do bmp.Canvas.Pixels[i,j]:=clred; SpeedButton26.Glyph:=bmp; bmp.Free; end; end;
var i,j:integer; bmp:tbitmap; begin if colordialog1.Execute then begin inic.WriteString('图层属性',t+'透空的颜色值',colortostring(colordialog1.Color)); bmp:=Tbitmap.Create; with bmp do begin Width:=13; Height:=12; Canvas.Brush.Color:=clRed; Canvas.FillRect(Canvas.ClipRect); SpeedButton26.Glyph:=bmp; Free; end; end; end;
var i,j:integer; bmp:tbitmap; begin if colordialog1.Execute then begin inic.WriteString('图层属性',t+'透空的颜色值',colortostring(colordialog1.Color)); bmp:=Tbitmap.Create; bmp.Width:=11; bmp.Height:=11; for i:=1 to bmp.Width-2 do for j:=1 to bmp.Height-2 do bmp.canvas.pixels[i,j]:=colordialog1.Color; SpeedButton26.Glyph:=bmp; bmp.Free; end; end;谢谢两位 这才是正确答案 BMP大小的问题....for i:=1 to bmp.Width-2 这就对了 或 for i:=1 to bmp.Width-1 都行 for i:=0 to bmp.Width-2也许 但是 for i:=0 to bmp.Width-1就不行 为什么肯定知道了哇...
procedure TForm1.Button1Click(Sender: TObject);
var
bmp:Tbitmap;
i,j:integer;
begin
bmp:=Tbitmap.Create;
bmp.Width:=100;
bmp.Height:=100;
for i:=0 to bmp.Width-1 do
for j:=0 to bmp.Height-1 do
bmp.Canvas.Pixels[i,j]:=clred;
bmp.SaveToFile('d:\tmp.bmp');
bmp.free;
end;
var
i,j:integer;
bmp:tbitmap;
begin
if colordialog1.Execute then
begin
inic.WriteString('图层属性',t+'透空的颜色值',colortostring(colordialog1.Color));
bmp:=Tbitmap.Create;
bmp.Width:=13;
bmp.Height:=12;
for i:=0 to bmp.Width-1 do
for j:=0 to bmp.Height-1 do
bmp.Canvas.Pixels[i,j]:=clred;
SpeedButton26.Glyph:=bmp;
bmp.Free;
end;
end;
i,j:integer;
bmp:tbitmap;
begin
if colordialog1.Execute then
begin
inic.WriteString('图层属性',t+'透空的颜色值',colortostring(colordialog1.Color));
bmp:=Tbitmap.Create;
with bmp do
begin
Width:=13;
Height:=12;
Canvas.Brush.Color:=clRed;
Canvas.FillRect(Canvas.ClipRect);
SpeedButton26.Glyph:=bmp;
Free;
end;
end;
end;
和一楼的效果完全一样...
保存成文件可以.但是直接赋值给SpeedButton26.Glyph就是空白....什么也没有!!!
在帮下忙可以不 郁闷一早上了.
或窗体上放一个image组件,image1.canvas.pixels[i,j]:=clred;SpeedButton26.Glyph:=image1.Picture.Bitmap;
i,j:integer;
bmp:tbitmap;
begin
if colordialog1.Execute then
begin
inic.WriteString('图层属性',t+'透空的颜色值',colortostring(colordialog1.Color));
bmp:=Tbitmap.Create;
bmp.Width:=11;
bmp.Height:=11;
for i:=1 to bmp.Width-2 do
for j:=1 to bmp.Height-2 do
bmp.canvas.pixels[i,j]:=colordialog1.Color;
SpeedButton26.Glyph:=bmp;
bmp.Free;
end;
end;谢谢两位 这才是正确答案 BMP大小的问题....for i:=1 to bmp.Width-2 这就对了 或 for i:=1 to bmp.Width-1 都行 for i:=0 to bmp.Width-2也许 但是 for i:=0 to bmp.Width-1就不行 为什么肯定知道了哇...