如何定义流或者使用流的方式
就是将Image1中的图片转换成流,再写入文件中
就是将Image1中的图片转换成流,再写入文件中
解决方案 »
- RichEdit 和 Image 的问题
- 存储过程中的高手请进来,求救呀~~先谢谢了
- 请各位大虾帮助,急急急!!!
- 【河南郑州的程序员看过来 . 2000-3000的底薪请你来开发 . 全职,兼职皆可 .】
- 怎样才能让DBGrid的某个字段下拉出一个Combobox或是一张表?
- ☺☻☺今天我生日!呵呵!~~快来灌水啊!!!~~☺☻☺
- 問題多,分數少,感興趣的近來。
- DBRichEdit中有text属性吗?
- 请大家帮忙参谋一下,本人是MCSE、MCDBA、OCP,如果到北京找工作,月薪大概多少钱???
- 对初学者来说不简单的问题
- 如何解决udl安全性的问题
- 求一个类似图片中的控件...
studentrecord=record //Word
xh,xm:string[8]; //学号,姓名
yw,sx:integer; //定义科目
ImageBufName:integer; //图片文件名
ImageBufSize:integer; //图片长度
ImageBuffers:PChar; //图片内容
end;
上面是记录集的结构............................
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;type
TForm1 = class(TForm)
Image1: TImage;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var
fileheader:tbitmapfileheader; //位图的文件头
infoheader:tbitmapinfoheader; //位图的信息头
stream:tfilestream;//文件流对象
localbmp:tbitmap; //位图对象
linelen:integer; //每一行像素长度
clipleft,cliptop,clipwidth,clipheight,bytecount:integer;
i:integer;
//j:integer; //位图倒立显示,变量
begin
form1.Width:=screen.Width;
form1.Height:=screen.Height;
form1.Top:=0;
form1.Left:=0;
self.DoubleBuffered:=true; //建立双缓冲
cliptop:=0;
clipwidth:=image1.Width;
clipheight:=image1.Height;
//将位图加载到文件流中
stream:=tfilestream.Create('2.bmp',fmopenread or fmsharedenywrite);
localbmp:=tbitmap.Create;//创建位图实例
stream.Read(fileheader,sizeof(tbitmapfileheader));//读取文件头数据
stream.Read(infoheader,sizeof(tbitmapinfoheader));//读取信息头数据
localbmp.Width:=clipwidth;
localbmp.Height:=clipheight;
localbmp.PixelFormat:=pf24bit;//设置为24位位图
bytecount:=3;
clipleft:=0;
//j:=clipheight-1;//位图倒立显示,变量
linelen:=(bytecount*infoheader.biWidth+3) shr 2 shl 2;
for i:=cliptop to cliptop + clipheight -1 do
begin
//设置新的指针位置
stream.Position :=integer(fileheader.bfOffBits) + linelen * (infoheader.biHeight-1-i) + bytecount * clipleft;
//stream.Read(localbmp.scanline[j-i]^,clipwidth * bytecount); //位图倒立显示
//将新的数据读进文件流中
stream.Read(localbmp.scanline[i-cliptop]^,clipwidth * bytecount);//位图正常显示
end;
image1.Picture.Bitmap.Assign(localbmp);
end;end.
我几个月前学图形编程的代码
因为要储存图片,你所要的实际上是一个自定义数据库。
可以考虑使用ACCESEE之类的数据库。
我做过自定义数据库,可以储存任何类型的数据。
盒子里好像有过资料管理类的源码,我做的也点像那,不过更复杂一些。
我就是想自己定义一个记录集的数据结构方式
文件内容结构如下:
就是数据类型不统一呀
[A0000001.JPG+56+sdfsdfsd]
图片文件+图片长度+图片内容
字符型 +数据型 +二进制型
学号 姓名 语文 数学 照片
每行为一个记录,包括上行信息段
type //定义记录集[结构]
studentrecord=record //Word
xh,xm:string[8]; //学号,姓名
yw,sx:integer; //定义科目
ImageBufName:integer; //图片文件名
ImageBufSize:integer; //图片长度
ImageBuffers:PChar; //图片内容
end;
t:studentrecord;
f:file of studentrecord;
write(f,t);
这样,就直接写入到数据中..........