先将24位图改为16位图
bmp:=Tbitmap.Create;
bmp.LoadFromFile(openpicturedialog1.FileName);
bmp.PixelFormat:=pf16bit;
image1.Assign(bmp);
bmp.free;
再读取每个象素的值并转为16进制
for n:=image1.picture.Width-1 downto 0 do
begin
bmpread:='';
str:='';
for m:=0 to image1.Picture.height-1 do
begin
k1:=ColorToRGB(image1.Canvas.Pixels[m,n]);
str:=inttohex(k1,4);
bmpread:=bmpread+str;
end;
memo1.Lines.Add(bmpread);
end;请大家看看哪里有问题?
我读取的值除了黑白之外都是错误的
bmp:=Tbitmap.Create;
bmp.LoadFromFile(openpicturedialog1.FileName);
bmp.PixelFormat:=pf16bit;
image1.Assign(bmp);
bmp.free;
再读取每个象素的值并转为16进制
for n:=image1.picture.Width-1 downto 0 do
begin
bmpread:='';
str:='';
for m:=0 to image1.Picture.height-1 do
begin
k1:=ColorToRGB(image1.Canvas.Pixels[m,n]);
str:=inttohex(k1,4);
bmpread:=bmpread+str;
end;
memo1.Lines.Add(bmpread);
end;请大家看看哪里有问题?
我读取的值除了黑白之外都是错误的
procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
tb : TBitmap;
RowOriginal : pRGBArray;
begin
if image1.Picture <> nil then
begin
Memo1.Clear;
pb.Visible := true;
tb := Image1.Picture.Bitmap;
pb.Max := tb.Height;
pb.Step := 1;
for i:=0 to tb.Height - 1 do
begin
pb.StepIt;
RowOriginal := pRGBArray(tb.Scanline[i]); for j:=0 to tb.Width - 1 do
begin
if (RowOriginal^[j].rgbtBlue = 0)and(RowOriginal^[j].rgbtGreen = 0)and(RowOriginal^[j].rgbtRed = 0) then
Memo1.Text := Memo1.Text + edtBlank.Text
else
Memo1.Text := Memo1.Text + edtWord.Text;
end;
Memo1.Text := Memo1.Text + #13#10;
end;
pb.Visible := false;
end;
end;
这句是什么意思??
保存了一行位图颜色数组