转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> Delphi程序 >> 正文
BCB存取图片等信息!         ★★★★

BCB存取图片等信息!

作者:闵涛 文章来源:闵涛的学习笔记 点击数:1738 更新时间:2009/4/23 18:37:24
nbsp;  dm_police->y_stress_man_photo->Append();
                dm_police->y_stress_man_photo->FieldByName("c_card")->Value=Edit3->Text;
                TBlobField * pField=(TBlobField *)dm_police->y_stress_man_photo->FieldByName("image_photo");
                TClientBlobStream * pmem=new TClientBlobStream(pField,bmWrite);
                pmem->Seek(0,soFromBeginning);
                //Graphics::TBitmap * pBitmap=new Graphics::TBitmap();
                TJPEGImage *pBitmap = new TJPEGImage();
                pBitmap->Assign(Image2->Picture->Graphic);
                pBitmap->SaveToStream(pmem);
                delete pmem;
                delete pBitmap;
                dm_police->y_stress_man_photo->Post();
                dm_police->y_stress_man_photo->ApplyUpdates(-1);
在http://expert.csdn.net/Expert/topic/1383/1383453.xml?temp=.9190485中有:
  Table1->Close();
        Table1->Open();
        Table1->Append();
        Table1->FieldByName("ID")->AsString=Edit1->Text.ToInt();
        Edit1->Text = StrToInt(Edit1->Text.ToInt()+1);
        Table1->FieldByName("Name")->AsString=OpenDialog1->FileName;
        Image1->Picture->LoadFromFile(OpenDialog1->FileName) ;

        TBlobField * pField=(TBlobField *)Table1->FieldByName("Entity");
        TStream *Stream2;
        TMemoryStream *tt=new TMemoryStream();
        Graphics::TBitmap * pBitmap=new Graphics::TBitmap();
        pBitmap->Assign(Image1->Picture->Graphic);
        pBitmap->SaveToStream(tt);

        pField->LoadFromStream(tt);
        Table1->Post();
说了这么多,你可能发现了,上边的代码都有一个共性,那就是用流来操作,好好,不知道你有没有发现呢!
TADOBlobStream:
Use c to access or modify the value of a BLOB or memo field in an ADO dataset. BLOB fields are represented by TBlobField objects and descendants of TBlobField such as TGraphicField and TMemoField.
TADOBlobStream allows objects that have no specialized knowledge of how data is stored in a BLOB field (raw binary data) to read or write such data by employing the uniform stream interface.
To use an ADO BLOB stream, create an instance of TADOBlobStream, use the methods of the stream to read or write the data, and then free the BLOB stream. Do not use the same instance of TADOBlobStream to access data from more than one record. Instead, create a new TADOBlobStream object every time you need to read or write BLOB data on a new record.
Use the Read method to copy the data from BLOB field object to a null-terminated string (or comparable) buffer. Use the Write method to copy from buffer to BLOB field object. When reading data from the BLOB field object, use the Size property to determine the volume of the field’s contents and to allocate the correct amount of space in memory for the receiving buffer.
TMemoryStream:
Use TMemoryStream to store data in a dynamic memory buffer that is enhanced with file-like access capabilities. TMemoryStream provides the general I/O capabilities of a stream object while introducing methods and properties to manage a dynamic memory buffer.
Memory streams are useful as intermediary objects that can hold information as well as read it from or write it to another storage medium. They provide a useful format for comparing the contents of streams, or for manipulating data that is stored in a less accessible medium.  TJPEGImage:
Use TJPEGImage to read and write jpeg compressed image data. TJPEGImage handles the digital compression and decompression of still images for use in computer systems. It uses the data from an instance of TJPEGData, which contains the actual jpeg data source and is never modified. Each jpeg image object may share its TJPEGData object with other instances of a jpeg image by creating copies using the Assign method. The jpeg data source handles reference counting for the jpeg image objects that are linked to it.
TJPEGImage has an internal bitmap that represents the jpeg image. This internal image and the original source of the jpeg image are read only. TJPEGImage has properties that determine how each instance will handle color conversion, compression, decompression, performance, and so on.
The following are characteristics of this object. A TJPEGImage object:
Has no canvas (so it cannot draw onto a canvas). However, TJPEGImage implements the protected Draw method introduced in TGraphic, so it can draw itself on the canvas of another object.
 Provides no access to the internal bitmap image that it creates for the JPEG image.
 Performs reference counting and handle sharing by means of the TJPEGData object. Multiple instances can refer to the same TJPEGData image. TJPEGData is the actual owner of the file handle to the jpeg data source.
TBlobField:
TBlobField encapsulates the fundamental behavior common to binary large object (BLOB) fields. BLOB fields are database fields that contain raw binary data of arbitrary length. BLOB fields can represent different arbitrarily large data types. These data types are distinguished in the header of the binary data.
In addition to the field types supported directly, TBlobField is the direct ancestor of two BLOB field components: TMemoField (ftMemo) and TGraphicField (ftGraphic). These descendants represent BLOB fields that have headers peculiar to memos or graphic data, respectively.
TBlobField introduces new methods to support streaming data to and from the BLOB field and to support copying raw binary data between the BLOB field and a binary file. You can also use the stream returned by a dataset’s CreateBlobStream method to read or write the data managed by a BLOB field.
If you use the Fields editor at design time to create a persistent field component for the BLOB field, you can access it by name at runtime. When using dynamic field components, you can access the TBlobField instance using the dataset’s Fields property or FieldByName method. 
TStream:
TStream is the base class type for stream objects that can read from or write to various kinds of storage media, such as disk files, dynamic memory, and so on.
Use specialized stream objects to read from, write to, or copy information stored in a particular medium. Each descendant of TStream implements methods for transferring information to and from a particular storage medium, such as a disk file, dynamic memory, and so on.  In addition to methods for reading, writing, and copying bytes to and from the stream, stream objects permit applications to seek to an arbitrary position in the stream. Properties of TStream provide information about the stream, such as its size and the current position in the stream.
TStream also introduces methods that work in conjunction with components and filers for loading and saving components in simple and inherited forms. These methods are called automatically by global routines that initiate component streaming. They can also be called directly to initiate the streaming process. Note, however, that component streaming always involves two additional objects:
A component object that is passed as a parameter to the stream’s methods.
A filer object that is automatically created by the stream, and associated with the stream.
TStream should not be instantiated; it relies on pure virtual methods that must be overridden in descendant classes. Descendant stream objects, such as memory and file streams used for component streaming, are created automatically by the global functions ReadComponentRes and WriteComponentRes. For streaming other kinds of information, choose a descendant class according to the specific data and storage needs.

 

上一页  [1] [2] 


没有相关教程
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台