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 

IMPORT of GIF

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



Joined: 13 May 2013
Posts: 25

PostPosted: Fri Nov 14, 2014 7:52 pm    Post subject: IMPORT of GIF Reply with quote

I have a graphic area with my symbols drawn on the area. I can successfully import a GIF file inside this area with the GIF commands. However, after redrawing my previous graphic area the colors of the previous screen has been changed. How can I avoid this, or how can I bring back my previous colors.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sat Nov 15, 2014 9:44 am    Post subject: Reply with quote

Is it possible to demonstrate this problem in a short program that we can look at?
Back to top
View user's profile Send private message AIM Address
Shahram



Joined: 13 May 2013
Posts: 25

PostPosted: Sun Nov 16, 2014 12:04 pm    Post subject: Re: Reply with quote

PaulLaidler wrote:
Is it possible to demonstrate this problem in a short program that we can look at?


The code is too complex to come here, I am trying to create a simplified code, however, you may see the problem in the following picture:

http://www.intelectri.com/salford/befgif.GIF

I use the routine DRAW_LINE@ to draw lines and so in my graphics.
Back to top
View user's profile Send private message
Shahram



Joined: 13 May 2013
Posts: 25

PostPosted: Sun Nov 16, 2014 3:52 pm    Post subject: Re: Reply with quote

Here is a simplified code that importing GIF change its original color:



Code:
     
      winapp 500000,500000
      options(intL)
      program TESTGIF
      include <windows.ins>
      common /hwndo/ hwnd
      integer*4 hwnd
      integer*4 i,r_x,r_y,r_x1,r_y1,ihandgr,bool
      integer*4 posx,POSy,ISTEPCUX,IMAXCUX,ISTEPCUY,IMAXCUY
      INTEGER*2 RX,RY,K2,M1C
      character*8 filename
      INTEGER*4     ERROR1
      integer*4 ixor
      INTEGER*4 exit_func
      external exit_func
      call vga@
      POSX=10
      POSY=10
      ISTEPCUX=10
      IMAXCUX=20
      ISTEPCUY=10
      IMAXCUY=20
      i=WINDOWS_95_FUNCTIONALITY@()
      r_x1 = clearwin_info@('SCREEN_WIDTH')
      r_y1 = clearwin_info@('SCREEN_DEPTH')
      r_x = r_x1/2
      r_y = r_y1/2
!     i=WINIO@('%cc&',exit_func)
!     i=winio@('%`gr[black,metafile_resize,FULL_MOUSE_INPUT]',r_x,r_y,IHANDGR)
      hwnd = clearwin_info@('latest_formatted_window')
!     call add_keyboard_monitor@(key_func)
      bool=1
      call use_approximate_colours@(bool)
      call SET_OLD_RESIZE_MECHANISM@
      K2=14
      CALL DRAW_LINE@(10,10,300,300,K2)
      FILENAME='P101.gif'
      ixor=0
      CALL IMPOGIF(FILENAME,ERROR1,ixor)
      call sleep@(4.0)
      CALL CLEAR_SCREEN@
      rx=ints(r_x)
      ry=ints(r_y)
!     M1C=0
!     CALL FILL_RECTANGLE@(0,0,rx,ry,M1C)
      K2=14
      CALL DRAW_LINE@(10,10,300,300,K2)
!     print *,'hwnd',hwnd,hwndorg
      end
!------------------------------------------------------------
      SUBROUTINE IMPOGIF(FILENAME,ERROR1,ixor)
      include <windows.ins>
      COMMON/ FILEDORG1/ FILEDORG
      CHARACTER*50 FILEDORG
      CHARACTER*(128) FILENAME
      INTEGER*4     ERROR1
      INTEGER*4     IIMAGE,NIMAGE
      INTEGER*4 RES
      CHARACTER*80 FILE
      COMMON /GRHAND/ IHANDGR
      INTEGER*4 IHANDGR
      integer*4 ixor
      CALL TRIM@(FILENAME)
      FILE=FILENAME(1:80)
      ERROR1=0
      IIMAGE=1
      NIMAGE=1
      RES=IMPORT_GIF@(FILENAME,IIMAGE,NIMAGE,ERROR1)
      call dib_paint@(0L,25L,res,ixor,0L)
      IF(ERROR1.NE.0)THEN
      PRINT *,'SOME ERROR OCCURED THE gif IS NOT FOUND'
      PRINT *,'The file ',FILE, ' is REQUIRED'
      ENDIF
      RETURN
      END
!------------------------------------------------------------
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Nov 17, 2014 8:13 am    Post subject: Reply with quote

The call to CLEAR_SCREEN@ is erasing the gif image. Just remove it.

Note also that USE_APPROXIMATE_COLOURS@ is for very old graphics displays (I forget the details - VGA or maybe before VGA).
Back to top
View user's profile Send private message AIM Address
Shahram



Joined: 13 May 2013
Posts: 25

PostPosted: Mon Nov 17, 2014 8:32 am    Post subject: Re: Reply with quote

Dear Paul,

The call to clear_screen@ is what I am using to erase the screen and then redraw my graphics again. Indeed this is necessary in my program to refresh the graphic area. Therefore, I can not remove that from my program.
This means that if I did not bring the GIF file, redrawing colors was O. right. Is there any other way for me to get back to the previous colors when I redraw my screen. Please see the effect on the WWW link I submitted in my previous quote.
On the other hand I can not use other colors instead of USE_APPROXIMATE_COLOURS@ since there are 30 years of networks available in my program, their colors standardize in the program, and can not be changed to other colors. I had not this problem with importing PCX files.
Back to top
View user's profile Send private message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 314
Location: Düsseldorf, Germany

PostPosted: Mon Nov 17, 2014 10:42 am    Post subject: Reply with quote

Sharam, if you like try this version. You can resize the window with the mouse, no colour changes appear.

Code:
      winapp
      program test
      implicit none
      include <windows.ins>
      external       testgif,u_res
      integer*4      j

      j = winio@('%ca[Test]%ww[topmost]%bg[black]%sc%pv%`^gr[user_resize,full_mouse_input,'&
          //'rgb_colours]',testgif,800L,600L,1L,u_res)
      end
 !------------------------------------------------------------
      INTEGER FUNCTION TESTGIF()
      include <windows.ins>
      integer*4      error1
      character*128  filename

      call draw_line_between@(10,10,300,300,rgb@(130,90,40))
      filename='P101.gif'
      call IMPOGIF(filename,error1)
      call sleep@(1.0)
      call draw_line_between@(10,10,300,300,rgb@(130,90,40))
      testgif = 1
      end
 !------------------------------------------------------------
      SUBROUTINE IMPOGIF(filename,error1)
      include <windows.ins>
      character*128  filename
      integer*4      res,error1
      c_external import_gif@ '__import_gif'(STRING,VAL,REF,REF) : integer*4
      common  /aaa/ res

      res = import_gif@(filename,1L,1L,error1)
      call dib_paint@(10L,25L,res,0L,0L)
      return
      end
 !------------------------------------------------------------
      INTEGER FUNCTION U_RES()
      include <windows.ins>
      integer*4      k,res
      common  /aaa/  res

      k = clearwin_info@('graphics_resizing')
      if (k == 1) then
        k = dib_paint@(10L,25L,res,0L,0L)
        call draw_line_between@(10,10,300,300,rgb@(130,90,40))
      end if
      u_res = 1
      end


Wilfried


Last edited by Wilfried Linder on Mon Nov 17, 2014 1:22 pm; edited 2 times in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Nov 17, 2014 1:16 pm    Post subject: Reply with quote

If you must "clear the screen" then you must also re-draw the gif image afterwards.
Back to top
View user's profile Send private message AIM Address
EKruck



Joined: 09 Jan 2010
Posts: 224
Location: Aalen, Germany

PostPosted: Mon Nov 17, 2014 4:20 pm    Post subject: Reply with quote

GIF file functions have predefined color palette which can be changed by the user. Clearwin+ is working with such a fixed color palette.

Like in other graphics programs it might be, that a call to GIF functions (e.g. "save as") changes or overwrites your color palette. Check the number of colors in your GIF input file; perhaps you have there only 8 colors. This might change your color palette.
It might help to change your GIF import file to 256 colors. If not, try to convert your GIF file logo to a PNG file. That has definitely a wide color palette.

Erwin
Back to top
View user's profile Send private message Visit poster's website
Wilfried Linder



Joined: 14 Nov 2007
Posts: 314
Location: Düsseldorf, Germany

PostPosted: Mon Nov 17, 2014 5:28 pm    Post subject: Reply with quote

... or load the GIF into a %gr region with the rgb_colours option like in my example above - then, the GIF graphics are converted into the 24-bits RGB colour space. As you can also see in my example, I always used RGB colours, for instance in the draw_line_between@ routine.

Whenever you resize the window, the GIF graphics is redrawn without any modification of colours (done by the U_RES function and within that by the dib_paint@ function) .

Wilfried
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Tue Nov 18, 2014 2:14 am    Post subject: Reply with quote

Try .png format and all the colour palette problems will go away.
John
Back to top
View user's profile Send private message
Shahram



Joined: 13 May 2013
Posts: 25

PostPosted: Thu Nov 20, 2014 10:58 am    Post subject: Reply with quote

Thank you all. The problem has been overcome with using DRAW_LINE_BETWEEN@ instead of DRAW_LINE@ . However, I had to go to RGB colors. This takes a lot of modifications inside my program, however, the colors are much more brighter and I decided to use RGB colors in my program.

Thanks all again.
Back to top
View user's profile Send private message
LitusSaxonicum



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

PostPosted: Thu Nov 20, 2014 11:07 am    Post subject: Reply with quote

Sharam,

RGB colours are the way forward - the other options take you back 20 years, and are computer archaeology!

Eddie
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