Read and Display JPG by increament

Moderator: Rathinagiri

Post Reply
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Read and Display JPG by increament

Post by hmgchang »

Dear All,
How to read a big JPG by steps and display instantly !
This is to decrease the waiting time to display the image in LAN.
Users prefer to hv the screen change gradually than waiting for
loading complete and image come out.!

Thks n rgds
Chang
Just Hmg It !
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Read and Display JPG by increament

Post by Javier Tovar »

Hola hmgchang,

Se tarda mucho en cargar la imagen?, yo aqui cargo imagenes *.jpg de pantalla completa 300KB en un segundo! en la LAN. o de cuantos KB son tus imagenes?

Saludos
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Read and Display JPG by increament

Post by Rathinagiri »

First we have to receive the bits to a temp file here. During this process, we can display the partial image in regular intervals. It is only a program logic I think.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: Read and Display JPG by increament

Post by hmgchang »

Thks Sirs,
and thats what my logic is about... but i dont know the functions to read Jpg file partially,
save as tempfile. usually on internet with slow connection we just take it for granted that
the browser will do the buffering. I really need Your guide on this.

TIA

rgds
Chang :D
Just Hmg It !
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Read and Display JPG by increament

Post by mol »

You can use .jpg files with interlace.
But I don't know how to realize displaying it. Maybe Claudio will know, he likes graphic functions :-D
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Read and Display JPG by increament

Post by Rathinagiri »

This is not an optimal solution.

First try a file from local picture file.

Please change 's ubstr' correctly. Our forum doesn't allow to enter s ubstr.

Code: Select all

#include <hmg.ch>

Function Main
   public cImageFile := ''
   public cTempFile := ''
   public cTempImageFile := ''
   define window x at 0, 0 width 1024 height 768 main title 'Image Buffering'
      define button browse
         row 10
         col 10
         width 80
         caption 'Browse'
         action browseimage()
      end button
      define image image1
         row 40
         col 10
         width 800
         height 600
      end image
   end window
   x.center
   x.activate
Return

function browseimage
   local oFHandle := Nil
   local cBuffer := space( 65000 )
   local nSize := 0
   local nsize1 := 0
   local lEoF := .f.
   local oNHandle := Nil
   cImageFile := getfile( , 'Select an Image File')
   if .not. file( cImageFile )
      msgstop( 'Error ' )
      return nil
   endif
   oFHandle := fopen( cImageFile, 0 )
   if oFHandle == -1
      return nil
   endif
   cTempImageFile := 'tempfile' + s ubstr( cImageFile, rat( '.',  cImageFile ), 4 )
   oNHandle := fcreate( cTempImagefile, 0 )
   if oNHandle < 0
      msgstop( 'File Creation Error!')
      return nil
   endif
   nSize := fseek( oFHandle, 0, 2 )
   nSize1 := nSize
   if nSize > 65000
      cBuffer := space( 65000 )
      nsize := 65000
   else
      cBuffer := space( nSize )   
   endif
   fseek( oFHandle, 0 )   
   do while .not. lEoF
      x := 0
      x := fread( oFHandle, @cBuffer, nSize )
      if x <= 0
         lEoF := .t.
      endif
      fwrite( oNHandle, cBuffer )
      fclose( oNHandle )
      cBuffer := space( 65000 )
      x.image1.picture := cTempImageFile
      oNHandle := fopen( cTempImageFile, 1 )
      fseek( oNHandle, 0, 2 )
   enddo
   fclose( oNHandle )
   fclose( oFHandle )
   x.image1.picture := cTempImageFile
   return nil
   
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
hmgchang
Posts: 273
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Re: Read and Display JPG by increament

Post by hmgchang »

Thks mr. Rathinagiri
I will look into it
Just Hmg It !
Post Reply