 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Tue Aug 04, 2009 3:09 pm Post subject: Problem exporting jpg image from %gr window |
|
|
I am trying to save an image from a %gr window to a jpg file, but I find two problems. Briefly, the program works as follows:
First imports a bmp image into the clearwin window with:
call clear_screen@
call perform_graphics_update@
call set_rgb_colours_default@(1)
call get_dib_size@(file,hres,vres,nb_colours,ier)
if(ier/= 0) STOP 'Problem'
call create_graphics_region@(2,hres,vres)
call use_rgb_colours@(2,1)
call select_graphics_object@(2)
ihfile = import_bmp@(file,ierr)
call dib_paint@(0l,0l,ihfile,0l,0l)
call copy_graphics_region@(1,0,0,800,600,2,0,0,hres,vres,srccopy)
call perform_graphics_update@
Then performs the determination of the image contour creating a new graphics region (3) where it draws points in red for contour and in white for backgraound and copies this image to the screen:
call create_graphics_region@(3,hres,vres)
call select_graphics_object@(3)
call draw_point@(i,j,red)
call draw_point@(i,j,white)
call clear_screen@
call copy_graphics_region@(1,0,0,800,600,3,0,0,hres,vres,srccopy)
call delete_graphics_region@(3)
call perform_graphics_update@
The %gr window now shows the graphics of region 3, but...when I set
ipc=export_image@('output2.jpg')
the red contour created in graphics region 3 and shown in the screen is not saved (just a white renctangle). If I do not call the clear_screen@, the original bmp image is saved as jpg ALTHOUGH it is no more shown in the window! Only the contour image appears in %dw!. And what is more intriguing, once the jpg image is saved, the program closes automatically! (it works like an Exit). Is anything wrong with my code or am I misunderstanding the use of export_image function?
Agustin |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Tue Aug 04, 2009 6:46 pm Post subject: |
|
|
Agustin,
The documentation for EXPORT_IMAGE@ says it is for a %gr - it says nothing about a %dw.
Eddie |
|
Back to top |
|
 |
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Tue Aug 04, 2009 9:05 pm Post subject: |
|
|
I am using a %gr not %dw. The very first part of the program says:
ans=winio@('%tc&',RGB@(255,0,0))
ans=winio@('%ca[An�lisis de Contornos de Colonias Celulares]&')
ans=winio@('%60`rs%nl&',file)
ans=winio@('%`gr[rgb_colours]&',800l,600l,1)
ans=winio@('%tc&',RGB@(0,0,255))
ans=winio@('%12`rs%bf%nl&',rotulo)
ans=winio@('%tc&',RGB@(255,0,0))
ans=winio@('%nl Rugosidad:.................%`5rf%ta&',width)
ans=winio@('%nl Distancia media:........%`5rf%2ta&',h_mean)
ans=winio@('%nl Dimension Fractal:.....%`5rf%ta&',slope)
ans=winio@('%nl Alfa:......................%`5rf%ta&',alfa)
ans=winio@('%bg[grey]%ww%lw&',ctrl)
ans=winio@('%mn[&Archivo[Circular,Lineal]]&', select_file_circular,select_file_lineal)
ans=winio@('%mn[~&Calcular contorno[Circular,Lineal]]&',krul,calcular_circular,calcular_lineal)
ans=winio@('%mn[~Exportar Imagen]&',krul2,exportar_imagen)
ans=winio@('%mn[E&xit]%nl','confirm_exit',str)
Agustin |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Wed Aug 05, 2009 1:34 am Post subject: |
|
|
You could try selecting the %gr region first, using
call select_graphics_object@(1)
It may help ?
Also, test the value of IPC for an error report. |
|
Back to top |
|
 |
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Wed Aug 05, 2009 3:34 am Post subject: |
|
|
Yes! it works! The only problem that I see now is that what I can export is the %gr window which is a stretched version of the real image that is located in the graphics region 83) with real dimensions...
and....well my second problem still persists: once I click in export image, the program exits! Quite strange, isn't it?
Finally: I do not understand why if I do not put "call select_graphics_object@(1)" the actual image in the screen (which is now in the %gr window) is not exported but the original one (which was originally imported into %gr but being replaced by the new image should not be in "graphics object 1" anymore!).
Agustin |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Thu Aug 06, 2009 1:55 am Post subject: |
|
|
Agustin,
To overcome your program stop, check your routine "exportar_imagen" identified in:
ans=winio@('%mn[~Exportar Imagen]&',krul2,exportar_imagen)
This should be (and declared) an integer function, which returns a value of 1: to continue running or 0: to stop the program.
With regard to dump file formats, I would also recommend that you consider alternative graphics formats, as .jpg (which is suitable for photos or colour transitions) is not suitable for engineering charts. I have used .pcx and recently .gif has been made available (see recent posts), which are more suitable for graphs with <128 colours.
.bmp is also available, but typically a very large file and we should lobby for .png , which I think is a replacement for .gif.
Support for importing .pcx into other packages, such as MS office 2003+, appears to be phased out so may not be a good solution.
I should again say that I am very appreciative of the general availability of .gif format, which is much better than the other formats for engineering charts or where the number of active colours is less than 128.
John |
|
Back to top |
|
 |
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Thu Aug 06, 2009 3:46 am Post subject: |
|
|
Well, in fact this function is defined as follows:
integer function exportar_imagen()
use datos_celulas
use mswin
integer ipc
output2=' '
place=index(archivo,'.')
output2(1:place-1)=archivo
output2(place:place+13)='-contorno.jpg'
call select_graphics_object@(1)
ipc=export_image@(output2)
exportar_imagen=1
end function exportar_imagen
so it takes 1 as the final value, but seems that the program thinks that it takes 0. I will debug it once again. And thanks for the advise about image formats. I will try with gif ones. I do not use MS Office but LaTeX, but I think gif files can also be used by LaTeX (or they can eventually be converted to pdf).
Agustin |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Fri Aug 07, 2009 12:39 am Post subject: |
|
|
Agustin,
Is "exportar_imagen" also declared integer and external in the menu definition ?
In %gr, you can trace information using "write (*,..." which goes to an output window when the program is running, without affecting the %gr window. It can be very useful.
John |
|
Back to top |
|
 |
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Fri Aug 07, 2009 1:22 am Post subject: |
|
|
Problem solved John! Seemingly the name of the function was misspelled in the version of the program that was running so it was never taking the value of 1!! Now it has been corrected and the window remains still active. Thanks for the tip about the use of write(...). I will use it in the future.
Agustin |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Fri Aug 07, 2009 8:20 pm Post subject: |
|
|
Oh Dear!
Now you have confessed to misspelling a variable name we are going to get deluged with comments that you should have used IMPLICIT NONE (sorry, implicit none - such programmers always use lower case!).
E |
|
Back to top |
|
 |
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Sat Aug 08, 2009 12:24 am Post subject: |
|
|
Well, in fact I "almost" always use "implicit none" for safety but in this case, I did a mistake. I do not why (maybe I was working till too late in the night) but I forgot the tiny sentence "implicit none". Sorry, sorry ,sorry...
Agustin |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|