replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Procedure to display images
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: 8210
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
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
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: 2923
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: 2923
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: 8210
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
DanRRight



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

PostPosted: Sat Oct 12, 2019 9:41 pm    Post subject: Reply with quote

Damn, i was wrong because yes do not read any manuals, relying just on common sense because Clearwin is now so large and mostly clean that there exist specific logic in its constructs. Sorry. you were right, and only now i noticed that brackets in my source code are indeed curly. Which tells me very strongly again and again that 4K for monitors is way too little if use native 100% font size on full 50" screen. This info will be useful if you plan to buy such monitors. Now I am waiting to switch to 8K monitors when they will be more affordable...Making terrible amount of typos and do not see them Sad

My common sense likes your suggestion for different name function. Curly brackets are way too unusual The current one IMPORT_IMAGE@ probably has to be renamed to something more clear like IMPORT_RESOURCE_IMAGE@. Since it is new function, just may be couple people are using it, this change will go fine, while IMPORT_IMAGE@ should have take regular files. To make change even simpler and add simplicity when failing to plot the warning could be added to use different name for the function.


Last edited by DanRRight on Sat Oct 12, 2019 11:29 pm; edited 2 times in total
Back to top
View user's profile Send private message
eric_carwardine



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

PostPosted: Sat Oct 12, 2019 10:13 pm    Post subject: Re: Reply with quote

PaulLaidler wrote:
If all else fails, read the documentation...


Thank you Paul.

I have the Clearwin+, Fortran edition, 436-page manual but it does not mention IMPORT_IMAGE@, only IMPORT_BMP@ and IMPORT_PCX@

Should I get documentation from the following list?



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
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