![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| Handling Files and Streams in Delphi I've been programming little amateur applications in Delphi for a long time, but one thing has always confused me. I've searched in vain for a tutorial on this exact subject, but so far a solution has eluded me. Basically, what I want to do is to write numerous different types of data into one big file. For example, I might want to store three JPGs and four integer values, then restore them. I've been looking at using TFileStream to do this, and I've managed to get it to write and read a single JPEG into a file which is great. However I can't get it to write two JPEG images into the same file, or rather I can get them to write in, but when I try to extract them again I only get the first JPEG out before the program shows an error message (JPEG error #42). The code is below. Can anyone tell me what I'm doing wrong? It's driving me crazy! 'Figure' is a variable of type TFileStream. 'Image' and 'Image1' are standard image components used for test purposes. File Writing Procedure: figure := tfilestream.Create('test.fig',fmcreate); image.Picture.Graphic.SaveToStream(figure); image1.Picture.Graphic.SaveToStream(figure); figure.Free; File Reading Procedure: figure := tfilestream.Create('test.fig',fmopenread); image.Picture.Graphic.LoadFromStream(figure); image1.Picture.Graphic.LoadFromStream(figure); figure.Free; Thanks in advance! Ash |
| |
| |||
| You misunderstand me. I don't want to store a JPEG IN integers, I want to save a JPEG in the same file as integer values, along with other JPEGs for that matter. I'm convinced that the problem is something to do with recalling the image from the file, rather than how I'm storing it though. Maybe there's another way to restore an image from stream, rather than using the loadfromstream command... Ash |
| |||
| Right, I think I've confirmed that the problem is not in how I'm writing the files; that I think I've sorted out to my own satisfaction. The problem is that the Graphic compenent isn't loading the image from the stream properly for some reason. I've tested this out by having the images saved back to file after extraction, and they come out just fine. So why can't I get it to load from a copied stream..? This is really, totally illogical. Ash |
| ||||
| Quote:
What kind of file you're talking about...? ASCII file? Or you're just wanted to write the name of the JPEG image... or... |
| ||||
| Its ok now mate, he has it fixed, glad to see you fixed it destriarch, would you care to post the answer? Just so in future when people look for the answer they can find it easily ![]() |
| |||
| Quote:
Ash |
| |||
| Ok Im the newest registered used. Hello Destriarch, Im now at same situation as you was in the past.... stucked into JPEG error while trying to retrieve the solid archive of jpeg images in DELPHI using LoadFromStream . I tried lot of searchs on internet and even tried to understand how do you fixed this But just cant got the thing working and im not any advanced user anyway. Can you post how the code must be done to have it working? Thanks in advance (dont care too much about my english,.... isnt my native language) Last edited by DanDare : 01-23-2008 at 07:53 PM. |
| The Following User Says Thank You to DanDare For This Useful Post: | ||
HelloWorld (01-23-2008) | ||
| |||
| sounds like you need a database buddy... store the data as BLOB's (Binary Large Objects) in the database and pull them out with Delphi __________________ Day Cares | Golf Courses | Disc Golf Courses | Campgrounds | Ice Rinks | Paintball Fields | Dentists | Plastic Surgeons | Aging Jokes Catholic Churches | Lutheran Churches | Methodist Churches | Episcopal Churches | Clean Jokes |
![]() |
| Thread Tools | |
| Display Modes | |
| |