PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → WB22 - dSaveImageJPEG
WB22 - dSaveImageJPEG
Débuté par André Labuschagné, 19 juil. 2018 23:56 - 9 réponses
Posté le 19 juillet 2018 - 23:56
Hi All

Anyone used this successfully in WB? If so, I would be interested in how you got it to work.

Cheers
André
Posté le 20 juillet 2018 - 09:48
Hi André,

Just like

dSaveImageJPEG(IMG_MeFB,fWebDir()+"\images_image.jpg")
Where [IMG_MeFB] is an image control.
Posté le 21 juillet 2018 - 03:37
Hi Peter

Thanks for that - it is not saving though.

I have checked out what the fwebdir returns on the development machine and then hardwired that to the web folder, the exe folder - nothing saves. I have no idea why. Any ideas?

Cheers
André
Posté le 21 juillet 2018 - 04:39
Hi Peter

I have now managed to get the web app to save but it is not saving the contents of the image. Getting closer. Here is the code:

In the button code on click in browser code:

MyImage..Value = StringFormat(LOOP_MyLooper[1].ATT_MyLooperImageNumber..Value,ccIgnoreSpace) + ".JPG"

This refreshes the image on the page and the correct image is displayed in MyImage.

Now I need to get this to the disk.

So I use another button using:

ExecuteProcess(MySaveButton,trtClick)

In MySaveButton server code I have:

IF dSaveImageJPEG(MyImage,"mywebimagefolder_image.jpg") = False THEN
Info(ErrorInfo())
END

It saves the contents of MyImage which is not the contents displayed in the browser. It saves a "blank" jpg file which is the contents of the MyImage control at startup - dynamic with zip file loaded.

I am suspecting that I need to use Ajax to get this to work.

Any ideas?

Cheers
André
Posté le 21 juillet 2018 - 05:29
Update

I have now got browser code to save correctly but it is still not saving the data in the image control. It is saving the contents of the control on startup which is squat.

Why, after assigning another image to a control does it not save that new image in that control?

Cheers
André
Posté le 21 juillet 2018 - 06:24
Update

For those following this I have now got the saving working - you can only save in browser code to what they call inMemory - one of the most confusing things I have ever encountered. What is the purpose of this? How do you access it after saving it? Really weird.

But the solution is to assign the new image in browser code else you will not see the change. But you have to assign in server code as well as that is the only way the server side will be aware of the change and then you save in server code and wallah - it all works.

On to the next problem - why dModifyLightness does not change the control at all. This was working before I got the saving sorted so my guess is that there is a sequencing issue going on here - the black box at work as it were.

Any ideas why dModifyLightness will not work and not return any errors I will be interested.

Cheers
André
Posté le 21 juillet 2018 - 09:41
Hi André,

The image type is set in design mode for the image control.
Dynamic types of image are generated by the Webdev engine and stored in a temporary file.
Static types of image are read from a direct link to the file itself.

In many cases the browser cache can prevent you from seeing any changes in an image on a page if the image filename has not changed.
Googling for cache disabling does not offer a good solution to disable caching, except in Chrome developer mode, but then developer mode has to be already active when the test starts
That's a bit inconvenient too.
I found a neat trick in some cases by putting a dummy parameter after the filename, then the browser sees a different filename each time.
e.g.: RTA_Score="<img src='/xxxxxx_web/data/mystaff.png?"+TimeSys()+"'>"
Kind regards,
Piet
Posté le 21 juillet 2018 - 14:04
Hi Piet

Cool. I will keep that in mind.

Browsers suck bigly. This is not programming - it is more like hacking and sparring with a 100kg out of control gorilla doing its own thing - and sometimes from vendor to vendor and browser version to browser version.

How I miss assembly or at least raw C.

:(

Cheers
André
Posté le 22 juillet 2018 - 00:20
Hi André

you REALLY need to watch all my webdev videos before you continue coding blindly like that...

Clearly, there are several very important principles that you do not understand and you will waste e huge amount of time if you continue like that..

By exemple, in this thread you complained because a save code in server code didn't save changes made to an image control in browser code...

This proves that you do not understand that browser code and sever code are executed on two different computers, as two different programs.

And the only thing that one side knows about the other is what has been EXPLICITELY SENT to the other side. There is no MAGIC at work... You either send things by code (in ajax) or do a SUBMIT button (for the EDIT FIELDS ONLY).

So changes to an image in browser code can NOT MAGICALLY APPEAR on the server side.

Take the time to learn before you continue... Or your problems will have no end.

Best regards
Posté le 22 juillet 2018 - 03:30
Hi Fabrice

You wrote:

>you REALLY need to watch all my webdev videos before you continue coding blindly like that...

I most certainly will. I will study them meticulously. And thanks a ton for making them available.

I always get flustered by black boxes so I have no idea what a command is actually doing and what it is not doing.

Cheers
André