Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#178246 - 08/09/2003 08:17 Creating a huge jpeg in code
JeffS
carpal tunnel

Registered: 14/01/2002
Posts: 2858
Loc: Atlanta, GA
I’m working in Delphi (of course), but all I need to know is if this can be done at all in any language. I don’t necessarily need help with a solution, just knowing that it’s possible would be enough.

My problem:
In code, I have to create a jpeg image that can potentially be absolutely huge. The problem is that the only way I know of to draw to a jpeg is to first write to a bitmap in memory and convert it to jpeg before saving. The problem here is that I cannot create a bitmap large enough in windows without getting an “out of memory” error. I CAN break the image up into several smaller bitmaps, but I don’t know how to put these together in order to save as a single jpeg. Basically my problem is how to write a huge jpeg without creating a large bitmap in memory to do it.

Any thoughts?
_________________________
-Jeff
Rome did not create a great empire by having meetings; they did it by killing all those who opposed them.

Top
#178247 - 08/09/2003 08:45 Re: Creating a huge jpeg in code [Re: JeffS]
Dylan
addict

Registered: 23/09/2000
Posts: 498
Loc: Virginia, USA
You could save the bitmap to disk and call a command line program to convert. But that might not be possible depending on the situation.

We create large images in our app but decided to go with PNG instead of jpg. PNG is supported pretty much everywhere that jpg is and it doesn't have any licensing concerns. We use libpng in our C++ code.

http://www.libpng.org/pub/png/pngaptk.html

The above link shows PNG support available in Delphi in a number of different ways - including a libpng port.

-Dylan

Top
#178248 - 08/09/2003 09:02 Re: Creating a huge jpeg in code [Re: Dylan]
JeffS
carpal tunnel

Registered: 14/01/2002
Posts: 2858
Loc: Atlanta, GA
The client wants JPG, so I really can't use a different format, though I will suggest PNG to him if you believe it will solve my problem.

As far a saving to disk first, I see two problems with that. The first is I have no idea how to draw a bitmap directly to disk (though certainly I could learn), the second is that this would be an absolutely huge file to process. Perhaps this would be ok, though. Do you have any suggestion on where I could look for how to draw bmps directly to file instead of memory (Delphi has a bunch of nice classes to do all of this for you, but none that write to a file instead of memory).
_________________________
-Jeff
Rome did not create a great empire by having meetings; they did it by killing all those who opposed them.

Top
#178249 - 08/09/2003 09:38 Re: Creating a huge jpeg in code [Re: JeffS]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Have you looked at this? I think it'll allow output directly to a file, although I'm not sure. But you can try it out for 30 days.
_________________________
Bitt Faulk

Top
#178250 - 08/09/2003 09:57 Re: Creating a huge jpeg in code [Re: wfaulk]
JeffS
carpal tunnel

Registered: 14/01/2002
Posts: 2858
Loc: Atlanta, GA
No, unfortunately it will still only allow you to save images first created in memory.
_________________________
-Jeff
Rome did not create a great empire by having meetings; they did it by killing all those who opposed them.

Top
#178251 - 08/09/2003 10:02 Re: Creating a huge jpeg in code [Re: JeffS]
JeffS
carpal tunnel

Registered: 14/01/2002
Posts: 2858
Loc: Atlanta, GA
Ok, I just had a flat forhead moment!

This bitmap has like 16 colors and I'm saving it in the default pixel format (number of colors). If I lower the pixel format down I should be able to write to the bitmap just fine!

Sorry for the thread folks. Move along, nothing to see here . . .
_________________________
-Jeff
Rome did not create a great empire by having meetings; they did it by killing all those who opposed them.

Top
#178252 - 08/09/2003 10:21 Re: Creating a huge jpeg in code [Re: JeffS]
peter
carpal tunnel

Registered: 13/07/2000
Posts: 4174
Loc: Cambridge, England
This bitmap has like 16 colors and I'm saving it in the default pixel format (number of colors). If I lower the pixel format down I should be able to write to the bitmap just fine!
The image has 16 colours, and the client requires it to be a JPEG? Sounds like it shouldn't be your forehead you should be slapping.

Peter

Top