如何显示??????????????????(100分)

  • 主题发起人 主题发起人 okbill
  • 开始时间 开始时间
O

okbill

Unregistered / Unconfirmed
GUEST, unregistred user!
我想用DBIMAGE显示数据库的*.bmp图像,只因其BMP文件太大,只看到一半,
如何可以让此大的BMP文件显示出来自动的适应我的DBIMAGE呢?而保不失真啊
 
用流吧,从数据库读出二进制流保存在.bmp文件,再通过控件把.bmp打开
 
DBImage.Stretch :=True;
 
Stretch :=True; 应该行的
 
楼上的,这样可失真了。
 
to :卷起千堆雪tyn,
是的这样可以就是失真太严重了,有没有更好的办法呢?让其自动适合,是缩小一起
整个一起缩小,放大整个放大,而不失真啊
 
设置DBIMAGE的autosize属性
并限制DBIMAGE大小嘛!
 
DBImage.Stretch :=True;
然后通过DBImage取得图片实际尺寸,按尺寸比例缩小。
实现方法:
将DBImage放在一Panel上,
比较Image的高和宽,
如果高大于宽,则图片缩小到hight := panel.height
width := panel.height / image actual height * image actual width
否则image width = panel.width
image height = panel.width / image actual width * image actual height

这样,只要你调好panel的大小,那么DBImage就会根据以上原则将图片自动适应
panel的宽和高(如果图片实际高大于宽,则缩小后高为panel高,
如果图片实际宽大于高,则缩小后宽为panel宽)
 
取图片实际大小:
image1.Picture.Width
image1.Picture.Height
 
再按比例缩放就是了
 
to: yhaochuan,
能给出具体的代码吗?本人是小菜没有办法?
 
来吧给些代码吧?
 
procedure TForm1.Table1AfterScroll(DataSet: TDataSet);
begin
if dbimage.Picture.Height >= panel1.height then
begin
dbimage.hight := panel.height;
dbimage.width := panel.height / dbimage.Picture.Height * dbimage.Picture.width;
end
else begin
dbimage.width = panel.width;
dbimage.height = panel.width / dbimage.Picture.width* dbimage.Picture.Height;
end;
end;
 
to :yhaochuan,
dbimage.height = panel.width / dbimage.Picture.width* dbimage.Picture.Height;
此名提示有错: “incopmpatialbe types:'integer and extended
 
不是吧,你把实数型结果转换成整数不就可以了,
不会吗?
 
dbimage的align要为alnone,
stretch要为True

if Image1.Picture.Height >= Image1.Picture.width then
begin
Image1.height := panel1.height;
Image1.width := round(panel1.height / Image1.Picture.Height * Image1.Picture.width);
end
else begin
Image1.width := panel1.width;
Image1.height := round(panel1.width / Image1.Picture.width* Image1.Picture.Height);
end;
 
to :yhaochuan
好像还是失真啊?有没有像ACDSEE软件一样啊,可以做到那好呢?
 
对了,当调完后要把dbimage在panel中的位置调好。
把dbimage放在panel的代码自己想,不难的.
思路:
如果图象和panel等高(接上面的代码的思路),则调左右位置;
如果图象和panel等宽,则调上下位置。
 
if Image1.Picture.Height >= Image1.Picture.width then
begin
Image1.height := panel1.height;
Image1.width := round(panel1.height / Image1.Picture.Height * Image1.Picture.width);
image1.top := 0;
image1.Left := round((panel1.Width - image1.Width) / 2);
end
else begin
Image1.width := panel1.width;
Image1.height := round(panel1.width / Image1.Picture.width* Image1.Picture.Height);
image1.Left := 0;
image1.top := round((panel1.height - image1.height) / 2);
end;
最好将panel.BevelInner和BevelOuter都设为alNone
将这个panel放在另一个panel上,
将此panel.BevelInner设为bvRaised
panel.BevvelOuter设为bvLowered。这样框框会有立体感。
 
接受答案了.
 
后退
顶部