Thread View: borland.public.cppbuilder.nativeapi
17 messages
17 total messages
Started by Jos�
Fri, 28 Apr 2006 20:16
Slow pictures
Author: Jos�
Date: Fri, 28 Apr 2006 20:16
Date: Fri, 28 Apr 2006 20:16
59 lines
2261 bytes
2261 bytes
Dear Remy and others
I am writing a program for a slideshow. It shows two different
pictures at once (stereo, yes).
The pictures appear very slowly.
Of course it takes time to load a picture, so that I used two pairs of
control elements, which are alternatively hidden.
The sequence is this:
screen becomes blank
after one second (or more) the left picture appears.
after another second (or more) the right picture appears.
Can anyone help me to get rid of those seconds?
--
Jos�
bool toggle;
void loadphotos()
{ fileL=.....
fileR=.....
TImage * ImageL;
TImage * ImageR;
if(toggle)
{ ImageL=Form1->Image1L; //Image1L, 1R, 2L, 2R are
ImageR=Form1->Image1R; //elements on the form
}
else
{ ImageL=Form1->Image2L;
ImageR=Form1->Image2R;
}
if(ImageL->Visible || ImageR->Visible)
error("error in program"); //does not occur
ImageL->Picture->LoadFromFile(fileL);
ImageR->Picture->LoadFromFile(fileR);
}
//------------------
void exchange(void)
{
Form1->Image1R->Visible=toggle;
Form1->Image1L->Visible=toggle;
Form1->Image2R->Visible=!toggle;
Form1->Image2L->Visible=!toggle;
toggle=!toggle;
}
static int semafoor=0;
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
exchange(); //display new pics
loadphotos(Sender); //load new pics and wait for Timer
}
Re: Slow pictures
Author: Hans Galema
Date: Fri, 28 Apr 2006 20:42
Date: Fri, 28 Apr 2006 20:42
59 lines
2463 bytes
2463 bytes
Jos� wrote:
> screen becomes blank
There is nothing in your code that cares for that. Please explain.
> after one second (or more) the left picture appears.
> after another second (or more) the right picture appears.
bool toggle;
void loadphotos()
Oh. Why are you using a global bool and a standalone function ?
It is much better to make that a classmember of TForm1.
If you do you could also use two forms which display
at the same time.
void exchange(void)
ditto.
__fastcall TForm1::TForm1(TComponent* Owner)
: TFrame(Owner)
{
// set the second set invisible
Image2R->Visible = false;
Image2L->Visible = false;
}
You could as well do all in the timereventhandler.
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Timer1->Enabled = false;
Image1R->Visible = ! Image1R->Visible;
Image1L->Visible = ! Image1L->Visible;
Image2R->Visible = ! Image2R->Visible;
Image2L->Visible = ! Image2L->Visible;
Application->ProcessMessages(); // does this have effect ?
FileR = ...
FileL = ...
if ( ! Image1R->Visible ) Image1R->Picture->LoadFromFile(fileR);
if ( ! Image2R->Visible ) Image2R->Picture->LoadFromFile(fileR);
if ( ! Image1L->Visible ) Image1L->Picture->LoadFromFile(fileL);
if ( ! Image2L->Visible ) Image2L->Picture->LoadFromFile(fileL);
Timer1->Enabled = true;
}
pProblems like this where you use a VCL component are better asked in:
borland.public.cppbuilder.vcl.components.using
Hans.
Re: Slow pictures
Author: Jos�
Date: Sat, 29 Apr 2006 08:10
Date: Sat, 29 Apr 2006 08:10
31 lines
1811 bytes
1811 bytes
On Fri, 28 Apr 2006 22:42:08 +0200, Hans Galema <notused@notused.nl> wrote in borland.public.cppbuilder.nativeapi: >> screen becomes blank > >There is nothing in your code that cares for that. Please explain. It happens. I think the TImages are made invisible intantanteously, but that it takes time to make them visible. Coding in the other order (first visible, then invisible) makes no difference. >> after one second (or more) the left picture appears. >> after another second (or more) the right picture appears. > >bool toggle; >void loadphotos() > >Oh. Why are you using a global bool and a standalone function ? I always do. Never had any problems with that. But I'll try your suggestion. >It is much better to make that a classmember of TForm1. >If you do you could also use two forms which display >at the same time. I expect this will make them behave more independently, causing a worse synchronisation. -- Jos�
Re: Slow pictures
Author: Jos�
Date: Sat, 29 Apr 2006 08:16
Date: Sat, 29 Apr 2006 08:16
10 lines
1192 bytes
1192 bytes
On Fri, 28 Apr 2006 22:42:08 +0200, Hans Galema <notused@notused.nl> wrote in borland.public.cppbuilder.nativeapi: >Oh. Why are you using a global bool and a standalone function ? > >It is much better to make that a classmember of TForm1. It makes no difference. Still too slow. -- Jos�
Re: Slow pictures
Author: Hans Galema
Date: Sat, 29 Apr 2006 09:04
Date: Sat, 29 Apr 2006 09:04
13 lines
1305 bytes
1305 bytes
Jos� wrote: > It makes no difference. Still too slow. How big are your pictures ? Are you still seeing that one picture displays one second before the other ? How long is your TTimer::Interval ? Could you post 4 pictures in borland.public.attachments so we can test in the same way? Hans.
Re: Slow pictures
Author: Hans Galema
Date: Sat, 29 Apr 2006 09:10
Date: Sat, 29 Apr 2006 09:10
14 lines
1310 bytes
1310 bytes
Jos� wrote: >>Oh. Why are you using a global bool and a standalone function ? >> >>It is much better to make that a classmember of TForm1. > > It makes no difference. Still too slow. No that makes no difference in speed of course. But did you try my code ? You did not even comment on ProcessMessages(). Hans.
Re: Slow pictures
Author: Jos�
Date: Sat, 29 Apr 2006 14:32
Date: Sat, 29 Apr 2006 14:32
23 lines
1617 bytes
1617 bytes
On Sat, 29 Apr 2006 11:04:25 +0200, Hans Galema <notused@notused.nl> wrote in borland.public.cppbuilder.nativeapi: >> It makes no difference. Still too slow. > >How big are your pictures ? Well, 500 kB to 1 MB, and 1000x1000 pixels or bigger. Perhaps I should make them smaller. But of course I do not want to loose quality, or I'll have to retain two copies of each picture: a big one for storage and a small one display. >Are you still seeing that one picture displays one second before >the other ? How long is your TTimer::Interval ? Yes >Could you post 4 pictures in borland.public.attachments >so we can test in the same way? I did. -- Jos�
Re: Slow pictures
Author: Jos�
Date: Sat, 29 Apr 2006 14:33
Date: Sat, 29 Apr 2006 14:33
14 lines
1455 bytes
1455 bytes
On Sat, 29 Apr 2006 11:10:14 +0200, Hans Galema <notused@notused.nl> wrote in borland.public.cppbuilder.nativeapi: >But did you try my code ? You did not even comment >on ProcessMessages(). Sorry, I didn't notice ProcessMessages in your code. I included it now, but it made no difference. I don't think there will be much difference between in-linde code and subroutines, but I prefer subroutines because they are called elsewhere in the program as well. -- Jos�
Re: Slow pictures
Author: JD
Date: Sat, 29 Apr 2006 17:30
Date: Sat, 29 Apr 2006 17:30
31 lines
2027 bytes
2027 bytes
Jos� <jose@127.0.0.1> wrote:
>
>>Could you post 4 pictures in borland.public.attachments
>>so we can test in the same way?
>
>I did.
Well they're not there.
What I know so far is that you're using TImages and relying
on them to do the painting when speed is an issue for you
you. This is a mistake. You need to be managing the painting
yourself and should be using a TBitmap instead.
The general order of operation should be:
1) Load the image
2) StretchDraw it to a bitmap in the appropriate size
3) Display it
4) While waiting for the timer, repeat 1 & 2 on the next image
5) Timer activates so begin at step 3
I have a print preview that zooms to 400% for 8.5 x 11 paper
and it's a huge bitmap that paints instantly because it uses
StretchDraw to a temporary bitmap that is then painted. If you
use StretchDraw directly to the screen, performance will
suffer greatly and I suspect that this is exactly what you're
doing by setting the Stretched property of the TImage.
~ JD
Re: Slow pictures
Author: Jos�
Date: Sat, 29 Apr 2006 18:29
Date: Sat, 29 Apr 2006 18:29
14 lines
1404 bytes
1404 bytes
On 29 Apr 2006 10:30:12 -0700, "JD" <nospam@nospam.com> wrote in borland.public.cppbuilder.nativeapi: >>>Could you post 4 pictures in borland.public.attachments >>>so we can test in the same way? >> >>I did. > >Well they're not there. I tried. The server rejects files which are bigger than 1 MB (small MB). Mine are approximately that size. -- Jos�
Re: Slow pictures
Author: Hans Galema
Date: Sat, 29 Apr 2006 21:10
Date: Sat, 29 Apr 2006 21:10
8 lines
1429 bytes
1429 bytes
Jos� wrote: > I tried. The server rejects files which are bigger than 1 MB (small > MB). Mine are approximately that size. Jpg or bmp ? Hans.
Re: Slow pictures
Author: Jos�
Date: Sat, 29 Apr 2006 21:35
Date: Sat, 29 Apr 2006 21:35
22 lines
1870 bytes
1870 bytes
On Sat, 29 Apr 2006 23:10:36 +0200, Hans Galema <notused@notused.nl> wrote in borland.public.cppbuilder.nativeapi: >> I tried. The server rejects files which are bigger than 1 MB (small >> MB). Mine are approximately that size. > >Jpg or bmp ? JPG. But of course you mean to say that 1MB is a lot for a JPG file. Well, I thin that smaller files will be faster indeed, but it amazes me that it takes time to make a picture visible, when it has already been loaded. I modified the program to skip loading new images, so that the program shows the same pictures all the time. This was a lot quicker, but there is still a noticeble delay. So there is obviously a delay in Visible=true. Perhaps I should try smaller files. -- Jos�
Re: Slow pictures
Author: Hans Galema
Date: Sat, 29 Apr 2006 21:39
Date: Sat, 29 Apr 2006 21:39
23 lines
1942 bytes
1942 bytes
Jos� wrote: > JPG. But of course you mean to say that 1MB is a lot for a JPG file. No. > Well, I thin that smaller files will be faster indeed, but it amazes > me that it takes time to make a picture visible, when it has already > been loaded. No, making visible does not take time here. The timeconsuming factor is in the loading. > I modified the program to skip loading new images, so that the program > shows the same pictures all the time. This was a lot quicker, but > there is still a noticeble delay. I did that too. But no delay. But when loading the invisible set there was delay between the left and right that were shown. I do not understand that. The delay about 1/3 s. Hans.
Re: Slow pictures
Author: Jos�
Date: Sun, 30 Apr 2006 09:47
Date: Sun, 30 Apr 2006 09:47
32 lines
2192 bytes
2192 bytes
On Sat, 29 Apr 2006 23:39:42 +0200, Hans Galema <notused@notused.nl> wrote in borland.public.cppbuilder.nativeapi: >No, making visible does not take time here. The timeconsuming factor >is in the loading. This was my modified program: wait 10 seconds. make pictures 1 and 2 invisible make pictures 3 and 4 visible wait 10 seconds. make pictures 1 and 2 visible make pictures 3 and 4 invisible repeat Note that no files were loaded. The pictures disappeared immediately, and then it took approximately a second for the other two pictures to appear, one by one. >> I modified the program to skip loading new images, so that the program >> shows the same pictures all the time. This was a lot quicker, but >> there is still a noticeble delay. > >I did that too. But no delay. > >But when loading the invisible set there was delay between the left and >right that were shown. I do not understand that. The delay about 1/3 s. As I say. -- Jos�
Re: Slow pictures
Author: Hans Galema
Date: Sun, 30 Apr 2006 10:48
Date: Sun, 30 Apr 2006 10:48
18 lines
1835 bytes
1835 bytes
Jos� wrote: > wait 10 seconds. > make pictures 1 and 2 invisible > make pictures 3 and 4 visible > wait 10 seconds. > make pictures 1 and 2 visible > make pictures 3 and 4 invisible > repeat Please in such case show actual code that compiles and links. Like I did. You are forcing people who want to help you do produce code that would handle that. As that can be coded in many ways one might look at different outputs. Hans.
Re: Slow pictures
Author: Mark Jacobs
Date: Tue, 02 May 2006 10:39
Date: Tue, 02 May 2006 10:39
21 lines
1828 bytes
1828 bytes
"JD" <nospam@nospam.com> wrote in message news:4453a2a4$1@newsgroups.borland.com... > The general order of operation should be: > > 1) Load the image > 2) StretchDraw it to a bitmap in the appropriate size > 3) Display it > 4) While waiting for the timer, repeat 1 & 2 on the next image > 5) Timer activates so begin at step 3 What function do you use for step 3? For example, in one of my programs I use :- Image1->Canvas->StretchDraw(Rect(0,0,wid,hei),mybitmp); Is this slow? Is there a faster way? -- Mark Jacobs DK Computing http://www.dkcomputing.co.uk
Re: Slow pictures
Author: Jos�
Date: Tue, 02 May 2006 13:04
Date: Tue, 02 May 2006 13:04
20 lines
1689 bytes
1689 bytes
On Tue, 2 May 2006 11:39:20 +0100, "Mark Jacobs" <http://www.jacobsm.com/mjmsg?Borland%20Newsgroup> wrote in borland.public.cppbuilder.nativeapi: >> 1) Load the image >> 2) StretchDraw it to a bitmap in the appropriate size >> 3) Display it >> 4) While waiting for the timer, repeat 1 & 2 on the next image >> 5) Timer activates so begin at step 3 > >What function do you use for step 3? For example, in one of my programs I use >:- > >Image1->Canvas->StretchDraw(Rect(0,0,wid,hei),mybitmp); > >Is this slow? Is there a faster way? Image->Visible=true; -- Jos�
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads