Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using JPEG with OLEBOUND Control does not show image. 3

Status
Not open for further replies.

randallJ

IS-IT--Management
Aug 15, 2000
90
GB
I want to produce a form that will alow users to import a jpg file. Currently I am using a general field in a table. It is important that the jpgs are embedded within a field in a table. However I can only seem to get it work with a bmp. I am using VFP6 and I understood that there is now native support for jpgs so why doesn't it work? When I use the append general command a icon appears with the name of the file as opposed to the image.

Any ideas will be greatly appreciated.

 
I had the identical problem (and haven't solved it, and there is none at the moment), because the support for JPG only goes for the picture control.

Unfortunately.



Weedz (The Grassman)
veld4663@exact.nl

They cling emotionally to code and fix development rather than choosing practices based on analytical assesments of what works best.

After the GoldRush - Steve McConnell
 
randallj

Try the following code which works here:-

CREATE TABLE test (FileName C(30), jpgimage G)
APPE BLAN
APPE GENE jpgimage FROM C:\gallery\1.jpg &&Relevant filename
BROW

Double click on General field to view

On your form use a OleBoundControl with .ControlSource as TEST.jpgImage

Chris
 
Chris,

The solution as you described forces your user to open another application (default MS Paint), which doesn't solve the problem of seeing the icon iso the JPG.
If you are looking for a certain image you will have to open the image in the general field for every record iso only having to scroll and view.

The only solution at this moment is to use BMP image files.

Does anyone know if this is solved in the new version of VFP (7.0), since I have this same problem in my current application in development, I am very anxious to know if this is solved in VFP 7.0.

Thanks anyhow,
Weedz (The Grassman)
veld4663@exact.nl

They cling emotionally to code and fix development rather than choosing practices based on analytical assesments of what works best.

After the GoldRush - Steve McConnell
 
Weedz

As I read Janet's post, I understood her to say she could not get an oleBoundControl to display a .jpg file.

This is not the case, oleBoundControls certainly will display .jpg files, and there is absolutely no need, unless you wish to edit the .jpg, to invoke the relevant graphics editor.

I have a sample form and table to illustrate the above and would happy to send it.

She also mentions that it's important to embed the .jpg files in the table.

IMHO, this should be avoided if at all possible.

Instead store the file references. Apart from saving huge amounts of disc space and improving performance, the user can be offered a choice of graphics editors and the image control can then replace the oleBoundControl.

Thumbnail previews can be provided in a grid as per thread184-39989 and the image control can be made to be zoom and scroll as per FAQ184-218

If I have misunderstood the original post, my apologies.

Chris
 
No offense intended Chris, just trying to help and thanks for the links. I'll have a look at it. And I'll be very gratefull if you could provide me with that form you mentioned.

Thanks,


Weedz (The Grassman)
veld4663@exact.nl

They cling emotionally to code and fix development rather than choosing practices based on analytical assesments of what works best.

After the GoldRush - Steve McConnell
 
Thanks Guys for your help.

Chris I will try your solution. Is it possible to preview the jpg in a report using this solution?

Your first sample of code is what I have in place at the moment and Weedz is right, if I activate its graphic editor I can view the JPG,however only the icon and file name is displayed on the form. Unless I am doing something wrong.(highly possible)

Thanks for the links. I would realy appreciate a copy of your sample form.

My email address is janet@alfred-ashley.co.uk.
 
Weedz

No offence taken

Janet

Yes - you can print/preview the .jpg in a report.

Am sending you both the sample form, but without Table1 which the form will create first time round, (ignore the error message).

To emphasize the comments about size problems that general fields create, the two sample .jpgs in their native form add up to to 72KB.

On this PC, Table1.fpt comes in at 5,453KB when you have appended just these 2 sample .jpgs, (Corel PhotoPaint 8.0, default editor), which is why I don't intend to spend a lot of time sending it!

Look forward to your comments.

Chris
 
Chris,

Thank you very much for the files. I think there may be something wrong with my PC, because I could still only view the JPEG as an icon with its filename. Also, perhpas as a result of this, the size of My table1 was only 80kb after appending both files.

However I am now using your suggested method of storing the images to a directory and referencing the file name.
This works fine and I can preview in a report, however there is still one small problem, I am unable to center the picture on my report. (Again a V. important request by my customer). The field option allows you to center picture but the file option doesn't. Any further ideas.

Thank you v much for your time and advice on this problem

Jae
 
Jae, there is 'Center Picture' property for the Picture box in report. Does it works? If it does not works, try also to use Clipping option and resize picture box to the size of the maximum picture.

Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Chris,

The 'Center Picture' property only works for general fields. I am using the clipping option - however the size of picture can vary from thumbnail to A4.

I am really impressed with the increase in performance since referencing the jpg files instead of embedding, so it looks like they will have to compromise.

Thanks again for all your help.

Jae

p.s.
If you do come accross a work around please let us know.

 
Jae

I deliberately left off LINK from the APPE GENE command in the sample form. I wanted to see if the oleObjects were being embedded in your general fields, which clearly is not happening. It appears the oleBoundControl cannot "see" the .jpg, embedded or not. If was working, you could use LINK and save a lot of space, but still have a performance problem.

I don't beleive you have a machine problem - I suspect there is an incompatability with the graphics editor associated with your .jpg files and FoxPro. You could try different associations through Windows and see if that resolves the issue.

The above is now academic for you, but may have some relevance for others.

As far as the object positioning is concerned, I do have an answer assuming you are printing only one image per report.

What you would need to do is create a report with a header band of 0.00, detail band of 29.6332 and footer band of 0.00, ie an A4 page.

You can place the picture control anywhere you like, (the code will determine the position), but any other controls should be in their correct position within the detail band.

If you can work with such a report, please advise and I will post the code.

Chris

 
Chris,

I am only printing one image per report, the image is the only field/data in the detail band however there is information in the footer.

If you think your code will work I would greatly appreciate a copy.

Jae
 
Jae

For simplicity, the following code assumes that you have copied the records you want to print to a cursor/table called PRINTOUT.

Your report is opened as a table and the picture centred north/south within the detail band and east/west within the report. The picture should be set to "clip" to enable it to resize.

If you need to centre the picture north/south within the report as opposed to north/south within the detail band, or further explanation, please advise.


lcAlias = ALIAS()

SELE PRINTOUT
SCAN
[tab]USE report1.frx IN 0 ALIAS TEMPREPO
[tab]SELE TEMPREPO
[tab]GO TOP && Locate width
[tab]lnReportWidth = TEMPREPO.Width && Report width
[tab]LOCATE FOR TEMPREPO.Objtype = 9;
[tab][tab]AND TEMPREPO.Objcode = 4 && Locate Detail band
[tab]lnReportHeight = TEMPREPO.Height && Detail band height
[tab]LOCATE FOR TEMPREPO.Objtype = 17 && Locate Picture
[tab]REPLACE TEMPREPO.Hpos WITH (lnReportWidth - TEMPREPO.Width) / 2,;
[tab][tab]TEMPREPO.Vpos WITH (lnReportHeight - TEMPREPO.Height) / 2
[tab]USE
[tab]SELE PRINTOUT
[tab]REPO FORM report1.frx NEXT 1 TO PRINTER NOCONSOLE
ENDSCAN

SELE (lcAlias)

Chris

 
Chris,

Thanks for the code.

Sorry to bother you yet again!

I have inserted the code into my app, making the necessary changes, however it does not repositiont he pictuer correctly - in fact what it appears to do is not to reposition, but to resize the picture width by /2. I have tried to juggle the code - but I have no idea what the different objtypes/codes are in temprepo. Is there any documentation on this?

Jae
 
Hi Jae,

There is very little documentation about the VFP metadata. You can start by reading this thread: thread184-27402

FWIW, Always backup your files before attempting to hack'em. Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Hi everybody,

Yesterday I tested above mentioned problem with the JPG on my machine with Windows ME and the latest version of Windows MediaPlayer. To my surpirse the OleBound control showed my JPG's as where it only showed an icon before (on the same machine).

So I guess the problem is that it needs some Codec dll to interpret the JPG in an olebound control.

Can anyone confirm my findings on his or her machine ??

Weedz (The Grassman)
veld4663@exact.nl

They cling emotionally to code and fix development rather than choosing practices based on analytical assesments of what works best.

After the GoldRush - Steve McConnell
 
Jae

The workaround as posted was not complete and on testing, needs further development. Apologies - too much haste, not enough speed!

The complication in your case, is that your .jpg files are of different sizes.

To overcome this, the picture object in the report would have initially been set to TEMPREPO.general = 1, (the .general field is numeric, and has values of 0 - Clip, 1 - Isometric, 2 - Stretch), and the object size increased to near maximum.

As the report accepted a new .jpg file, the TEMP.general field's value would have been replaced with 0, Clip, which would then have allowed the picture object to resize itself, according to the .jpg's dimensions.

The picture object would then have been centred prior to print.

All this works in the command window, but does not currently work in the application.

One workaround, and this may sound a retrograde step, would be to APPE GENE each .jpg to a cursor, and centre the image in the report.

IF LINK is included, only the .jpg would be embedded, and only 1 image would ever be in RAM at one time. As the printing of the images would be the most time consuming, the APPEnding time would probably be acceptable.

Assuming the records have been copied to cursor PRINTOUT, and a general field called .image added to PRINTOUT then:-

lcAlias = ALIAS()

SELE PRINTOUT
SCAN
[tab]lcFileName = PRINTOUT.filename
[tab]APPE GENE image FROM &lcFileName LINK && Append image
[tab]REPO FORM report1.frx NEXT 1 TO PRINTER NOCONSOLE
[tab]APPE GENE image && Remove old image
ENDSCAN

SELE (lcALias)

Chris
 
Guys,

Looks like I have come full circle.

I like the idea of referencing to a file - this is great on performance so I'm sticking with it, however I do need to print to a report and the picture does need to be centered.

Chris your idea of appending the jpg to a temporary file for reporting purposes only and deleting is one that I have tried to implement previous, but I have the same problem. I can only see the icon. I am using Windows NT and I have tried associating .jpg with many graphics editors, but I cannot get it to work. Is there an editor that is free (i.e. comes with an operating system or is downloadable ) that you know works?)


Jae
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top