Why Doesn't this work....

Why Doesn't this work....

Post by topprolm » Fri, 15 Oct 1999 04:00:00



procedure TForm1.BitBtn1Click(Sender: TObject);
var
Fst:tfilestream;
begin
if openpicturedialog1.execute then
 begin
 Image1.picture.LoadFromFile(openpicturedialog1.filename);
  fst:=tfilestream.Create('c:\abc.123',fmcreate);
  image1.Picture.Graphic.SaveToStream(fst);
  fst.Free;
  image1.picture.Assign(nil);
 end;
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
var
Fst:tmemorystream;
begin
if opendialog1.execute then
 begin
   fst:=tmemorystream.Create;
   fst.LoadFromFile(opendialog1.filename);
  image1.Picture.Graphic.loadfromStream(fst);  <<<<<<<------ AV here....
at 00447821. Read
                                                        of address FFFFFFFF
  fst.Free;
  end;
end;

This should work....Shouldn't it?
--
Topp

 
 
 

Why Doesn't this work....

Post by Yoram Halbersta » Fri, 15 Oct 1999 04:00:00


Dear topprolmc,

After executing
image1.picture.assign(nil)

you did set the Graphic member to nil, so when calling on button2

Image1.Picture.Graphic.DoSomething

IT WILL CRASH

Dr. Delphi


> procedure TForm1.BitBtn1Click(Sender: TObject);
> var
> Fst:tfilestream;
> begin
> if openpicturedialog1.execute then
>  begin
>  Image1.picture.LoadFromFile(openpicturedialog1.filename);
>   fst:=tfilestream.Create('c:\abc.123',fmcreate);
>   image1.Picture.Graphic.SaveToStream(fst);
>   fst.Free;
>   image1.picture.Assign(nil);
>  end;
> end;

> procedure TForm1.BitBtn2Click(Sender: TObject);
> var
> Fst:tmemorystream;
> begin
> if opendialog1.execute then
>  begin
>    fst:=tmemorystream.Create;
>    fst.LoadFromFile(opendialog1.filename);
>   image1.Picture.Graphic.loadfromStream(fst);  <<<<<<<------ AV here....
> at 00447821. Read
>                                                         of address FFFFFFFF
>   fst.Free;
>   end;
> end;

> This should work....Shouldn't it?
> --
> Topp


 
 
 

Why Doesn't this work....

Post by topprolm » Fri, 15 Oct 1999 04:00:00


Even if I don't assign the graphic member to nil and just execute the
'BitBtn2Click' method, I get the same error.  I am loading the file
abc.123


> Dear topprolmc,

> After executing
> image1.picture.assign(nil)

> you did set the Graphic member to nil, so when calling on button2

> Image1.Picture.Graphic.DoSomething

> IT WILL CRASH

> Dr. Delphi


> > procedure TForm1.BitBtn1Click(Sender: TObject);
> > var
> > Fst:tfilestream;
> > begin
> > if openpicturedialog1.execute then
> >  begin
> >  Image1.picture.LoadFromFile(openpicturedialog1.filename);
> >   fst:=tfilestream.Create('c:\abc.123',fmcreate);
> >   image1.Picture.Graphic.SaveToStream(fst);
> >   fst.Free;
> >   image1.picture.Assign(nil);
> >  end;
> > end;

> > procedure TForm1.BitBtn2Click(Sender: TObject);
> > var
> > Fst:tmemorystream;
> > begin
> > if opendialog1.execute then
> >  begin
> >    fst:=tmemorystream.Create;
> >    fst.LoadFromFile(opendialog1.filename);
> >   image1.Picture.Graphic.loadfromStream(fst);  <<<<<<<------ AV here....
> > at 00447821. Read
> >                                                         of address FFFFFFFF
> >   fst.Free;
> >   end;
> > end;

> > This should work....Shouldn't it?
> > --
> > Topp

--
Topp
 
 
 

Why Doesn't this work....

Post by Steve Schafer (Tea » Fri, 15 Oct 1999 04:00:00


On Thu, 14 Oct 1999 17:46:26 -0400, topprolmc


>This should work....Shouldn't it?

No, because there is no graphic object contained within the Picture
object. If it's a bitmap, you need to instantiate it first:

 Image1.Picture.Graphic := TBitmap.Create;

-Steve

 
 
 

Why Doesn't this work....

Post by topprolm » Fri, 15 Oct 1999 04:00:00



> On Thu, 14 Oct 1999 17:46:26 -0400, topprolmc

> >This should work....Shouldn't it?

> No, because there is no graphic object contained within the Picture
> object. If it's a bitmap, you need to instantiate it first:

>  Image1.Picture.Graphic := TBitmap.Create;

Ahhhhh.  I am enlightened....  Thank you sir!

--
Topp

 
 
 

Why Doesn't this work....

Post by Steve Schafer (Tea » Sat, 16 Oct 1999 04:00:00


On Thu, 14 Oct 1999 19:49:45 -0400, topprolmc


>I am enlightened....

Wow, that was easy. :)

-Steve

 
 
 

Why Doesn't this work....

Post by Kay Schube » Sat, 16 Oct 1999 04:00:00


On Thu, 14 Oct 1999 17:46:26 -0400, topprolmc

<snip>

Quote:>procedure TForm1.BitBtn2Click(Sender: TObject);
>var
>Fst:tmemorystream;
>begin
>if opendialog1.execute then
> begin
>   fst:=tmemorystream.Create;
>   fst.LoadFromFile(opendialog1.filename);
>  image1.Picture.Graphic.loadfromStream(fst);  <<<<<<<------ AV here....

Sorry, but in TPicture is no auto-detection-of-image-type based on the
contents of a stream. TPicture.LoadFromFile uses the file ext to
initialize its Graphic property with the appropiate TGraphic
descendant, and then calls its LoadFromStream method. You miss this
initialization, so Graphic is nil (even if it isn't nil but someone
TGraphic descendant instance, it won't adaptate to the appropiate
TGraphic descendant - it just expects to find data of its own image
type in the stream).
Quote:>at 00447821. Read
>                                                    of address FFFFFFFF
>  fst.Free;
>  end;
>end;

>This should work....Shouldn't it?
>--
>Topp

 
 
 

1. Why doesn't this work!?

Hi folks-

I'm trying to get a small sphere to orbit a larger sphere. (I'll add
interesting details to the spheres later...) I've never tried to do the
animation before, and thought this wouldn't be too tough.

When I render the sences, nothing changes! It has to be something simple,
but it escapes me. Any help would be nice.

Thanks in advance!
Norman

----------------------------------
scene file:
#include "colors.inc"
#include "textures.inc"

camera {
   location < 0, 50, 0 >
   look_at 0
   angle 36

// light_source { < 700, 200, -50 > White }
light_source { < -500, 0, 10 > White }
// light_source { < -10, -5, -10 > Red }

plane { y, -25
   texture {
      pigment { Yellow }
      finish { reflection .5 specular 1 ambient 0.3 }
   }

sphere { < 0, 0, 0 > 2
        texture {
                pigment { Red }
        }

sphere { < 0, 0, 0 > .5
        texture {
                pigment { Blue }
                finish { reflection 0.9
                        specular 1
                        phong 1 phong_size 20
                        metallic
                }
        }
        translate < 5*cos(radians(clock)), 0, 5*sin(radians(clock)) >

------------------------------------------
animation ini file:
; Persistence Of Vision raytracer version 3.0 sample file.

Antialias=Off

Antialias_Threshold=0.2
Antialias_Depth=3

Test_Abort_Count=100

Input_File_Name=planet.pov

Initial_Frame=0
Final_Frame=9
Initial_Clock=0
Final_Clock=2*pi

Cyclic_Animation=on
Pause_when_Done=off

Width=320
Height=200
Display=off


                             |  it to makes voodoo seem like a science.
http://www.geocities.com/CapeCanaveral/5280

2. Multi-monitor Support for DirectX

3. why doesn't this work

4. light help wanted-strobing lights/streaming lights??

5. newbie Q: why doesn't snowfall work?

6. Looking to Pursue a Job with Computer Animation.. Looking for comments/ Advice

7. Why doesn't this work?

8. Anybody wants to work with me?

9. Why doesn't this work???

10. Why doesn't this work ??

11. Why doesn't glGetString work?

12. Why doesn't it work?

13. Why doesn't this work?