Home > Archive > Programming with dBASE > November 2005 > Copy Image to Binary field









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Copy Image to Binary field
John Jay

2005-11-08, 3:58 pm

David Stone and I trying to transfer image files into binary fields
programaticly.
By using keyboard() we are able to load the file into the viewer (see
previous post Image display in image field) but are unable to save it to the
file.The problem is that the viewer dose not surface its onclose/save to
binary field methods.
I woukd like to build a form with a image image field then use it's
datasource to load the desired image file.
At that point I need a method like the viewer uses to put the image into
the binary field.
Anyone have a better idea?
Any body know the Db methoud/procedure used by the image viewer, Or should
we put a post in the dde-ole-API newsgroup?

Thanks
John Jay
Best Marine


John Jay

2005-11-08, 3:58 pm

Hi all
I forgot to do the obvious
OLH is the answer, replace binary
also a search of the newsgroups had the answer in a 1999 post
Will I ever learn?

Opps!
John Jay
Best Marine



Ivar B. Jessen

2005-11-08, 3:58 pm

On Tue, 8 Nov 2005 08:31:49 -0800, "John Jay"
< beat_nospam_mar@sbcg
lobal.net> wrote:

>David Stone and I trying to transfer image files into binary fields
>programaticly.
>By using keyboard() we are able to load the file into the viewer (see
>previous post Image display in image field) but are unable to save it to the
>file.The problem is that the viewer dose not surface its onclose/save to
>binary field methods.
>I woukd like to build a form with a image image field then use it's
>datasource to load the desired image file.
>At that point I need a method like the viewer uses to put the image into
>the binary field.
>Anyone have a better idea?
>Any body know the Db methoud/procedure used by the image viewer, Or should
>we put a post in the dde-ole-API newsgroup?


Try the code below. is this what you are attempting to do?


Ivar B. Jessen

//-----
close tables
if file("SQLImages.dbf")
drop table SQLImages
endif
create table SQLImages(name char(30), billede blob(0,2))


** END HEADER -- do not remove this line
//
// Generated on 08-11-2005
//
parameter bModal
local f
f = new sqlbilledeForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif

class sqlbilledeForm of FORM
with (this)
onOpen = class::FORM_ONOPEN
height = 11.4545
left = 40.4286
top = 11.5909
width = 69.4286
text = ""
endwith

this.SQLIMAGES1 = new QUERY()
this.SQLIMAGES1.parent = this
with (this.SQLIMAGES1)
left = 16.0
top = -0.0455
sql = 'select * from "sqlimages.DBF"'
active = true
endwith

this.IMAGE1 = new IMAGE(this)
with (this.IMAGE1)
height = 10.0
left = 3.0
top = 1.0
width = 32.0
dataSource = form.sqlimages1.rowset.fields["billede"]
endwith

this.PUSHBUTTON1 = new PUSHBUTTON(this)
with (this.PUSHBUTTON1)
onClick = class::PUSHBUTTON1_O
NCLICK
height = 1.0909
left = 44.0
top = 9.0
width = 15.2857
text = "Pushbutton1"
endwith

this.LISTBOX1 = new LISTBOX(this)
with (this.LISTBOX1)
height = 7.5
left = 37.0
top = 1.0
width = 31.0
id = 105
dataSource = form.sqlimages1.rowset.fields["name"]
endwith

this.rowset = this.sqlimages1.rowset

function form_onOpen
form.a = new array()
form.a.dir("*.jpg")
form.b = new array(form.a.size/5)
for i = 1 to form.a.size/5
form.b[i] = form.a[i,1]
next
form.listbox1.datasource := "array form.b"
return

function PUSHBUTTON1_onClick
cfile = this.parent.listbox1.selected()
if empty(cFile)
return
endif
local r
r = this.parent.SQLimages1.rowset
r.beginAppend()
r.fields["billede"]. replaceFromfile(cfil
e)
r.fields["name"].value := cFile
r.next(0)
return
endclass
//-----


Ken Mayer [dBVIPS]

2005-11-08, 3:58 pm

John Jay wrote:
> Hi all
> I forgot to do the obvious
> OLH is the answer, replace binary
> also a search of the newsgroups had the answer in a 1999 post
> Will I ever learn?


I see Ivar got to the field["fieldname"].replaceFromFile() method.

Ken

--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/dbase/dBASEBook.htm
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
John Jay

2005-11-08, 8:23 pm


Ivar,

> Try the code below. is this what you are attempting to do?

I will adapt the code.. My task is a little more straight forward. My Image
names are contained in a table along with their path. After I convert them
using IrfanView as you suggested in a previous post a loop throught the
table using
cfile=form.myfile.rowset.fields["picturefile"].value)
. replaceFromfile(cfil
e)
should do the job

Thanks again
John Jay
Best Marine


evilaro

2005-11-08, 8:23 pm

John:

I must have lost something...

If you have a field with the full path of the image you want to show...

Why do you need a binary field...

You could just do

form.image1. datasource='filename
'+ form.entryfield1.value

What is the pourpose of the binary field??

Emilio


"John Jay" < beat_nospam_mar@sbcg
lobal.net> escribió en el mensaje
news:B9FcdRL5FHA.1240@news-server...
>
> Ivar,
> I will adapt the code.. My task is a little more straight forward. My

Image

> names are contained in a table along with their path. After I convert

them
> using IrfanView as you suggested in a previous post a loop throught the
> table using
> cfile=form.myfile.rowset.fields["picturefile"].value)
> . replaceFromfile(cfil
e)
> should do the job
>
> Thanks again
> John Jay
> Best Marine
>
>



David Stone

2005-11-09, 3:23 am

John Jay wrote:

> David Stone and I trying to transfer image files into binary fields
> programaticly.


Yes, but I want to be able to paste the image into the binary field from the
clipboard (not from a disk file---standard behavior covered in OLH). For
example, OLE-create a graph in Excel, OLE-select the image in Excel, OLE-copy to
clipboard, then back in the dBASE app, paste it from the clipboard into a binary
field so it can be displayed in an image control in a dBASE form.

David

John Jay

2005-11-09, 1:23 pm


evilaro
> I must have lost something...
> If you have a field with the full path of the image you want to show...
>
> Why do you need a binary field...
> What is the pourpose of the binary field??

Originally I had two needs, Ivar Jessen solved that one with a non dbase
approach.
Second I am making up a demo and do not want to the user to be unable to
copy the way I usually display images or how my program works. I can include
the images in a table that I add to a form.
The image is in the binary field that displays at the top of your Form (an
image of my app), a memo field displays at the bottom with explanations of
what the real form does.
My idea is to display the "what it does" without giving away the "How it is
done" .

David's needs are dfferent, see his post in this thread.
John Jay
Best Marine


John Jay

2005-11-09, 1:23 pm

Emilio
I forgot to mention that when I sell my app I will use a increpted file
with the images in a binary field to prevent coping.

John Jay
Best Marine


evilaro

2005-11-09, 1:23 pm

John

Thanks for the clarification.

Emilio

"John Jay" < beat_nospam_mar@sbcg
lobal.net> escribió en el mensaje
news:NZVdx5V5FHA.584@news-server...
> Emilio
> I forgot to mention that when I sell my app I will use a increpted file
> with the images in a binary field to prevent coping.
>
> John Jay
> Best Marine
>
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com