forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Procedure to display images
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
eric_carwardine



Joined: 13 Jun 2009
Posts: 70
Location: Perth, Western Australia

PostPosted: Sat Oct 05, 2019 6:01 am    Post subject: Procedure to display images Reply with quote

Hallo! Smile

Is there a Clearwin procedure to display images within a Fortran program?

Images such as .jpg, .jpeg, .gif, .bmp, .png

Eric

_________________
"Covid-19 is the codename for the Trojan Horse bearing world totalitarianism."
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Smib



Joined: 26 Apr 2009
Posts: 22
Location: Melbourne

PostPosted: Sat Oct 05, 2019 7:40 am    Post subject: Reply with quote

Eric,

This is some F77 style code I used several years ago to add a logo defined in a resource file to a plot. I found it necessary to plot the image (in my case a bmp) offscreen and then copy it to the graphics screen as I could not get my printer to scale the graphic any other way. I am sure there are other neater ways, Some of the code is superfluous but it should give you some idea of how it can be done.

Brian
Code:

C      plot bmp to offscreen region, copy and scale and then copy back to plot
C      This is necessary because printer will not scale graphics

        r_handle=30
        hres=0
        vres=0
        if(hres.le.1)hres=768
        if(vres.le.1)vres=89
        rat=hres/vres
        call create_graphics_region@(r_handle,hres,vres)
        call use_rgb_colours@(r_handle,1) 
        call select_graphics_object@(r_handle)

        i=IMPORT_IMAGE@('{logo.bmp}',0,0)

        call create_graphics_region@(j_handle,5*hres,5*vres)
        call use_rgb_colours@(j_handle,1) 
        call select_graphics_object@(j_handle)

        hres1=bscale
        vres1=bscale*vres/hres
        factor=size/real(50) 
        offsetx=19
        offsety=262 
        x1=((offsetx+0*factor)*scale+.5)
        y1=((offsety+0*factor)*scale+.5)
               
        call copy_graphics_region@
     +(j_handle,0,0,hres1,vres1,r_handle,0,0,hres,vres,SRCCOPY)

         factor=size/real(50) 
         offsetx=19
         offsety=262 
         x1=((offsetx+0*factor)*scale+.5)
         y1=((offsety+0*factor)*scale+.5)
         hres1=hres1
         vres1=vres1
         call select_graphics_object@(hnd1)

         call copy_graphics_region@
     +(g_handle,x1,y1,hres1,vres1,j_handle,0,0,hres1,vres1,SRCCOPY)

         call window_update@(hnd1)
         call perform_graphics_update@

         k=close_printer@(hnd2) 
C   note printer opened in earlier subroutine

Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat Oct 05, 2019 8:14 am    Post subject: Reply with quote

Images can be displayed by calling winio@. For example, using %bm or %im or %ic plants an image directly to the Window. Alternatively you can use %gr to create a drawing surface and then call import_image@ to draw the image.

iw = winio@("%im[myimage]")
end
RESOURCES
myimage IMAGE "file.jpg"

or....

iw = winio@("%gr&", 300,300)
iw = winio@("%lw",ictrl)
ir = import_image@("file.jpg",0,0)
Back to top
View user's profile Send private message AIM Address
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Sat Oct 05, 2019 6:28 pm    Post subject: Reply with quote

Documentation Alert ! - Need for Clarification ?

Reading up on these techniques I came across:- USE_GDIPLUS_IMAGE_FILES@

Quote:
The documented description of which says:-

When GDI+ image loading is turned on a wider range of file types can be loaded with the subroutines GET_DIB_SIZE@, GET_DIB_BLOCK@ and IMPORT_IMAGE@. Passing 1 for STATE will turn on the use of GDI+, passing 0 will turn it off. Off is the default state.



The documentation for GET_DIB_BLOCK@ for example reflects this with a x-reference back to it.

But where is the list of these 'wider range of file types' documented ?

... or are they simply the 5 filetypes already documented for IMORT_IMAGE@ ?

P.S.
Eric .... G'day cobber Smile
Nice signature' you have there by the way Smile
Something we should all never forget.
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
eric_carwardine



Joined: 13 Jun 2009
Posts: 70
Location: Perth, Western Australia

PostPosted: Sun Oct 06, 2019 2:57 am    Post subject: Re: Reply with quote

G'day Brian! Smile

Smib wrote:
Eric,

This is some F77 style code I used several years ago to add a logo defined in a resource file to a plot.

Brian


That caught my eye, Brian. I will re-visit your approach when I've completed my current project.

I had a logo created for my newly-formed public relations business but it's far too large. Visit http://www.movethefence.com.au

Several other files were also supplied by the logo-designer but at a first glance I couldn't see any provision for scaling down.

Eric
_________________
"Covid-19 is the codename for the Trojan Horse bearing world totalitarianism."
Back to top
View user's profile Send private message Send e-mail Visit poster's website
eric_carwardine



Joined: 13 Jun 2009
Posts: 70
Location: Perth, Western Australia

PostPosted: Sun Oct 06, 2019 3:25 am    Post subject: Re: Reply with quote

Thank you Paul! Smile

PaulLaidler wrote:
Images can be displayed by calling winio@. For example, using %bm or %im or %ic plants an image directly to the Window. Alternatively you can use %gr to create a drawing surface and then call import_image@ to draw the image.

iw = winio@("%im[myimage]")
end
RESOURCES
myimage IMAGE "file.jpg"

or....

iw = winio@("%gr&", 300,300)
iw = winio@("%lw",ictrl)
ir = import_image@("file.jpg",0,0)


How would I modify the code if there were a large number of image files?

For example:

Code:

      character file_path(1000)*100


The project is to organize the very large number of images I've photographed as part of my public relations business, using the RENAME function (which can also re-locate - MOVE):

The essence being the following test program, using Force 2.0 Fortran:

Code:

      integer status
      character path1(1000)*100, path2(1000)*100
C
      path1(1) = 'f1\test_file.txt'
C
      path2(1) = 'f2\test_file.txt'
C
      status = rename( path1(1), path2(1) )
C
      write(*, 11) status
11    format(' Status = ', i10/)
C
      pause
      end
 


And it worked! Smile



Eric
_________________
"Covid-19 is the codename for the Trojan Horse bearing world totalitarianism."
Back to top
View user's profile Send private message Send e-mail Visit poster's website
eric_carwardine



Joined: 13 Jun 2009
Posts: 70
Location: Perth, Western Australia

PostPosted: Sun Oct 06, 2019 3:42 am    Post subject: Re: Reply with quote

G'day John! Smile

John-Silver wrote:

Eric .... G'day cobber Smile
Nice signature' you have there by the way Smile
Something we should all never forget.


Yes, 'cobber', a salutation as rare in Australia these days as rocking-horse excreta.

Humans are hard-wired to learn; we hate being taught cf Winston Churchill (apologies for any mis-quoting) ~

Code:

"I will not allow schooling to interfere with my education."


Learn all you can while you can. It'll keep the 'Ol-Timer's' (Alzheimer's) at bay.

P.S. Anybody found a bio for Al Zhe Imer?

P.P.S. All the best in searching for a clarification. I'm sure others will be keen followers of your expedition.
_________________
"Covid-19 is the codename for the Trojan Horse bearing world totalitarianism."
Back to top
View user's profile Send private message Send e-mail Visit poster's website
eric_carwardine



Joined: 13 Jun 2009
Posts: 70
Location: Perth, Western Australia

PostPosted: Sun Oct 06, 2019 3:55 am    Post subject: Re: Reply with quote

G'day again, Paul!

My example code should, of course, have included a preview of the image.

PaulLaidler wrote:
Images can be displayed by calling winio@. For example, using %bm or %im or %ic plants an image directly to the Window. Alternatively you can use %gr to create a drawing surface and then call import_image@ to draw the image.


Code:

      integer status
      character path1(1000)*100, path2(1000)*100
C
C section to preview the image file
C and most likely rename it to something
C more searchable
C
      path1(1) = 'f1\test_file.txt'
C
      path2(1) = 'f2\test_file.txt'
C
      status = rename( path1(1), path2(1) )
C
      write(*, 11) status
11    format(' Status = ', i10/)
C
      pause
      end
 


Eric
_________________
"Covid-19 is the codename for the Trojan Horse bearing world totalitarianism."
Back to top
View user's profile Send private message Send e-mail Visit poster's website
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Sun Oct 06, 2019 6:32 pm    Post subject: Reply with quote

You'r emy kinda bloke Eric .... I could see myselìf playing 'Back Yard Ashes' agains you Wink lol

Well done getting the prog working.
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
eric_carwardine



Joined: 13 Jun 2009
Posts: 70
Location: Perth, Western Australia

PostPosted: Mon Oct 07, 2019 10:02 am    Post subject: Re: Reply with quote

John-Silver wrote:

Well done getting the prog working.


Not yet fully working John; need to determine if "file.jpg" in the code following can be a character-array element, such as file_path(k).

Code:

iw = winio@("%im[myimage]")
end
RESOURCES
myimage IMAGE "file.jpg"

or....

iw = winio@("%gr&", 300,300)
iw = winio@("%lw",ictrl)
ir = import_image@("file.jpg",0,0)


P.S. "Backyard Ashes" could be very lively with the New Cricket ...

http://www.movethefence.com.au/exhibits/cricket04.jpg

Ewik aka Eric aka Nobody-in-particular
_________________
"Covid-19 is the codename for the Trojan Horse bearing world totalitarianism."
Back to top
View user's profile Send private message Send e-mail Visit poster's website
eric_carwardine



Joined: 13 Jun 2009
Posts: 70
Location: Perth, Western Australia

PostPosted: Tue Oct 08, 2019 9:29 am    Post subject: Re: Reply with quote

G'day again, Paul;

PaulLaidler wrote:
Images can be displayed by calling winio@. For example, using %bm or %im or %ic plants an image directly to the Window. Alternatively you can use %gr to create a drawing surface and then call import_image@ to draw the image.

iw = winio@("%im[myimage]")
end
RESOURCES
myimage IMAGE "file.jpg"

or....

iw = winio@("%gr&", 300,300)
iw = winio@("%lw",ictrl)
ir = import_image@("file.jpg",0,0)


I wrote a short program using the second code option Paul but I think it's missing something. See the code below and the two attached files.

Perhaps I need the full path specs for the image file dad09.jpg or a URL?

Code:

      PROGRAM main
C
      use clrwin
C
      integer iw,winio@
C
      iw = winio@("%gr&", 300,300)
      iw = winio@("%lw",ictrl)
      ir = import_image@("dad09.jpg",0,0)
C
      pause
C
      END PROGRAM main





_________________
"Covid-19 is the codename for the Trojan Horse bearing world totalitarianism."
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Thu Oct 10, 2019 9:51 pm    Post subject: Reply with quote

Indeed, this code does not work.
As usually anything in Clearwin is simple but always needs WORKING examples.
Back to top
View user's profile Send private message
Smib



Joined: 26 Apr 2009
Posts: 22
Location: Melbourne

PostPosted: Thu Oct 10, 2019 11:00 pm    Post subject: Reply with quote

Think you need curly brackets. Try

i=IMPORT_IMAGE@('{file.jpg}',0,0)
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sat Oct 12, 2019 2:01 am    Post subject: Reply with quote

I am curious how you got the solution but for all other users this hack is called a BUG which will take 100 swearing-at-effing-Clearwin man-years to find Sad

Looks like Paul was doing surgery of import_image@ and forgot the scissors inside Smile

And i was guessing why couple my tools stopped working
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat Oct 12, 2019 8:07 am    Post subject: Reply with quote

If all else fails, read the documentation...

INTEGER FUNCTION IMPORT_IMAGE@( RSCNAME, X, Y )

"RSCNAME is linked to a file via a resource script or is a file name enclosed in curly brackets."

Sample code is also provided.

I suppose an alternative function with a different name could be provided, but then you would still have to read the documentation in order to find out which function to use.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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