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 

Using _dib_block@

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Mon Dec 21, 2009 5:46 am    Post subject: Using _dib_block@ Reply with quote

I have been attempting to install a logo on the screen of my graphics, and used the ..._dib_block@ routines. I am confused with the offset addresses in the examples for array PARRAY, as the array goes from 1:aw, where as the arguments imply they go from 0:aw-1.
The program appears to work ok, but could the documentation identify more clearly if the dimensions are 0:aw, 0:aw-1 or 1:aw, for the array PARRAY.

Also, is it possible to scale the .bmp file in these routines when using get_dib_block@, or should I do that in paint before reading the .bmp file ?
In my testing, it appears to clip the .bmp file, rather than performing scaling.

The routine I have quickly written is:
Code:
      SUBROUTINE draw_logo
!
      use simulation_data
      use yrdplt_info
!
      INCLUDE <clearwin.ins>
      INCLUDE <jdc_menu.ins>
!
      integer*4 hres, vres, nb_colours, ier, ix, iy
      integer*4 dib_read
!
      integer*4, parameter :: aw = 115
      integer*4, parameter :: ah = 112
      character parray(3,aw,ah)
      save parray
      data dib_read / -99 /
!
      if ( dib_read == -99) then
!
         call get_dib_size@ ('small_logo.bmp', hres, vres, nb_colours, ier)
         if (ier /= 0) then
            dib_read = 99
            write (*,*) 'logo trouble (call get_dib_size@)'
            return
         end if
         write (*,*) 'logo size = ', hres, vres, nb_colours
!
         call get_dib_block@ ('small_logo.bmp', parray, aw, ah, 0, 0, hres, vres, 0, 0, ier)
         if (ier /= 0) then
            dib_read = 99
            write (*,*) 'logo trouble (call get_dib_block@)'
            return
         end if
         write (*,*) 'logo size now = ', aw, ah, ier
         dib_read = 0
!
      end if
!
      if (dib_read == 0) then
         ix = s_width - aw - 9
         iy = 15
         call display_dib_block@ (ix, iy, parray, aw,ah, 0,0, aw,ah,  0, 0, ier)
         if (ier /= 0) then
            dib_read = 99
            write (*,*) 'logo trouble (call display_dib_block@)'
            return
         end if
      end if
!
      end SUBROUTINE draw_logo
Back to top
View user's profile Send private message
Smib



Joined: 26 Apr 2009
Posts: 22
Location: Melbourne

PostPosted: Thu Jan 07, 2010 2:56 am    Post subject: Reply with quote

John

I finally dug out a piece of code that I created when I was trying to resize a photograph. I used a simpe pixel averaging approach (in one direction only) that was adequate for my needs. It may assist

Code:
 

         file=photodwg
         call get_dib_size@(file,hres,vres,nb_colours,ier)
            if(hres.gt.0)then
       call get_dib_block@(file,a,1024,1024,0,0,hres,vres,0,0,ier)

         if(vres.eq.0)vres=1
         if(hres.eq.0)hres=1
         
c       scale bitmap

        fact=real(hres+1)/(scale*(150.))
        fact1=real(vres+1)/(scale*(75.))
        if(fact.gt.fact1)fact=fact1         
        ihres=real(hres)/fact
        ivres=real(vres)/fact
        if(ihres.eq.0)ihres=1
        if(ivres.eq.0)ivres=1
 
        if(ivres.gt.5000) then
         fact=real(vres)/5000
         ivres=5000
         ihres=real(hres)/fact
        end if

        x=((15+201)/2.)*scale+offsetx-real(ihres)/2.
        y=165.*scale+offsety
        y=(pagetop+97)*scale+offsety
     
         do iijj=1,ihres
         do j=1,ivres
          i=1
          ii=float(i)*fact+.5
          ii=float(iijj)*fact+.5
          jj=float(j)*fact+.5
        if(ii.le.1)ii=2
        if(jj.le.1)jj=2
        if(jj.le.0)jj=1
         kk=0
         kk=kk+ichar(a(1,ii,jj))           
         kk=kk+ichar(a(1,ii,jj))           
          b(1,i,j)=char(kk/2)
         kk=0
         kk=kk+ichar(a(2,ii,jj))           
         kk=kk+ichar(a(2,ii,jj))           
          b(2,i,j)=char(kk/2)
         kk=0
         kk=kk+ichar(a(3,ii,jj))           
         kk=kk+ichar(a(3,ii,jj))           
          b(3,i,j)=char(kk/2)
        end do
      call display_dib_block@
     +(x,y,b,500,5000,0,0,1,ivres,0,0,ier)
        x=x+1
        end do

        end if
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Thu Jan 07, 2010 1:06 pm    Post subject: Reply with quote

That looks like hard work. Can't you do it more easily with IMPORT_IMAGE@?

If you use CLEARWIN_INFO@ to find GRAPHICS_WIDTH and GRAPHICS_DEPTH, you can find the midpoint of the graphics area, and then arrange for the image to be in the centre - you could even select a different-sized image to import depending on the space available and its x:y aspect ratio.

If this is in the callback for the graphics region (i.e. selecting a different image based on size available), and the graphics region has the %pv pivot, you get a very professional-looking response to a screen resize.

I find IMPORT_IMAGE@ to be very fast as well as simple to use, and the routines involving DIB blocks much more difficult.

Eddie
Back to top
View user's profile Send private message
Smib



Joined: 26 Apr 2009
Posts: 22
Location: Melbourne

PostPosted: Thu Jan 07, 2010 11:29 pm    Post subject: Reply with quote

John, Eddie

Playing around last night came up with another way of resizing. Full code would need to copy from an off screen plotting surface rather than back to same surface as indicated below:

Code:


      integer*4 hDib,res,hres,vres,nb_colours,ier

                         
! import bmp file and plot

      hDib = import_bmp@('brit16.bmp',res)
      call get_dib_size@('brit16.bmp',hres,vres,nb_colours,ier)
      res = dib_paint@(0,0,hDib,0,0)

! stretch the bitmap horizontally by 2 and plot at ixpos,iypos

      res=copy_graphics_region@(0,ixpos,iypos,2*hres,vres,0,0,0,hres,vres,SRCCOPY)
       call release_screen_block@(hDib)
Back to top
View user's profile Send private message
Smib



Joined: 26 Apr 2009
Posts: 22
Location: Melbourne

PostPosted: Thu Jan 07, 2010 11:30 pm    Post subject: Reply with quote

John, Eddie

Playing around last night came up with another way of resizing. Full code would need to copy from an off screen plotting surface rather than back to same surface as indicated below:

Code:


      integer*4 hDib,res,hres,vres,nb_colours,ier

                         
! import bmp file and plot

      hDib = import_bmp@('brit16.bmp',res)
      call get_dib_size@('brit16.bmp',hres,vres,nb_colours,ier)
      res = dib_paint@(0,0,hDib,0,0)

! stretch the bitmap horizontally by 2 and plot at ixpos,iypos

      res=copy_graphics_region@(0,ixpos,iypos,2*hres,vres,0,0,0,hres,vres,SRCCOPY)
       call release_screen_block@(hDib)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
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