Page 1 of 1
Read and Display JPG by increament
Posted: Thu Apr 17, 2014 3:11 am
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
Re: Read and Display JPG by increament
Posted: Thu Apr 17, 2014 3:29 am
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
Re: Read and Display JPG by increament
Posted: Thu Apr 17, 2014 4:35 am
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.
Re: Read and Display JPG by increament
Posted: Thu Apr 17, 2014 6:49 am
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

Re: Read and Display JPG by increament
Posted: Thu Apr 17, 2014 7:28 am
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

Re: Read and Display JPG by increament
Posted: Thu Apr 17, 2014 2:47 pm
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
Re: Read and Display JPG by increament
Posted: Mon May 12, 2014 6:51 am
by hmgchang
Thks mr. Rathinagiri
I will look into it