Hi,
I would like to include pictures into an internal database like (Name, FirstName, Picture etc.). How can I insert pictures into such a database
Thanks for your reply
- Thomas Linder Puls
- VIP Member
- Posts: 1424
- Joined: 28 Feb 2000 0:01
Re:
That means a visual representation of a person. See as follows:
class facts - db_pic
db_pic : (string Name,string FirstName, picture Picture).
predicates
onPaint : drawWindow::paintResponder.
clauses
onPaint(_Source, Rectangle, GDI):-
retractAll(db_pic(_,_,_)),
FileName="Hydrangeas1.bmp",
Pic=vpi::pictLoad(fileName(FileName),100,100,0x0020),
file::delete("db_pic.bmp"),
assert(db_pic("Meier","Tom",Pic)),
file::save("db_pic.bmp",db_pic),
GDI:pictDraw(Pic, pnt(250,10), rop_SrcCopy),
W= pictOpen(Rectangle),
Pic= pictClose(W),
retractAll(db_pic(_,_,_)),!.
onPaint(_Source, _Rectangle, _GDI).
Picture appears into the dialog; but it seems to be, that the picture is not included into the database as mentioned. When database is reloaded, there is no picture at all.
class facts - db_pic
db_pic : (string Name,string FirstName, picture Picture).
predicates
onPaint : drawWindow::paintResponder.
clauses
onPaint(_Source, Rectangle, GDI):-
retractAll(db_pic(_,_,_)),
FileName="Hydrangeas1.bmp",
Pic=vpi::pictLoad(fileName(FileName),100,100,0x0020),
file::delete("db_pic.bmp"),
assert(db_pic("Meier","Tom",Pic)),
file::save("db_pic.bmp",db_pic),
GDI:pictDraw(Pic, pnt(250,10), rop_SrcCopy),
W= pictOpen(Rectangle),
Pic= pictClose(W),
retractAll(db_pic(_,_,_)),!.
onPaint(_Source, _Rectangle, _GDI).
Picture appears into the dialog; but it seems to be, that the picture is not included into the database as mentioned. When database is reloaded, there is no picture at all.
- Thomas Linder Puls
- VIP Member
- Posts: 1424
- Joined: 28 Feb 2000 0:01
OK, so the problem is saving and loading the vpiDomains::picture.
However a vpiDomains::picture is actually a pointer to "something":
If you save a pointer and load it again "another day" it will point to something different (or nothing at all).
You can however obtain a binary that represents the image, and that binary can be saved and loaded and reconverted into a picture (in the vpi class):
So if you let the database contain the binary-picture instead of the pointer-picture it can be saved and loaded.
(It will however use a lot of disk space)
However a vpiDomains::picture is actually a pointer to "something":
Code: Select all
domains
picture = pointer.
% @short Handle to a picture.
% @end
You can however obtain a binary that represents the image, and that binary can be saved and loaded and reconverted into a picture (in the vpi class):
Code: Select all
predicates
pictToBin : (vpiDomains::picture Picture) -> binary Binary language c as runtimeLinknamesVpi::pict_ToBin.
% @short Converts the #Picture picture into the #Binary binary format.
% @detail Binary has exactly the same format as BMP file.
% @end
predicates
pictFromBin : (binary Binary) -> vpiDomains::picture Picture language c as runtimeLinknamesVpi::pict_FromBin.
% @short Retrieves the #Picture picture from the #Binary binary. <br>
% @detail Binary has exactly the same format as BMP file.
% @end
(It will however use a lot of disk space)
Regards Thomas Linder Puls
PDC
PDC
Re:
Thanks Thomas, any other way using pictures at the least possible disk space.Thomas Linder Puls wrote:OK, so the problem is saving and loading the vpiDomains::picture.
However a vpiDomains::picture is actually a pointer to "something":
If you save a pointer and load it again "another day" it will point to something different (or nothing at all).Code: Select all
domains picture = pointer. % @short Handle to a picture. % @end
You can however obtain a binary that represents the image, and that binary can be saved and loaded and reconverted into a picture (in the vpi class):
So if you let the database contain the binary-picture instead of the pointer-picture it can be saved and loaded.Code: Select all
predicates pictToBin : (vpiDomains::picture Picture) -> binary Binary language c as runtimeLinknamesVpi::pict_ToBin. % @short Converts the #Picture picture into the #Binary binary format. % @detail Binary has exactly the same format as BMP file. % @end predicates pictFromBin : (binary Binary) -> vpiDomains::picture Picture language c as runtimeLinknamesVpi::pict_FromBin. % @short Retrieves the #Picture picture from the #Binary binary. <br> % @detail Binary has exactly the same format as BMP file. % @end
(It will however use a lot of disk space)
Regards
- Tonton Luc
- VIP Member
- Posts: 204
- Joined: 16 Oct 2001 23:01
Hi,
as you can see in the help file :
as you can see in the help file :
Code: Select all
binary::compress/1->
compress : (binary Input)
-> binary Output
language c.