 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
sduguay Guest
|
Posted: Tue Sep 19, 2006 1:27 am Post subject: pf32bit? |
|
|
I have a bmp file which when I loadfromfile sometimes gives me the error message 'Bitmap image is not valid.' I have traced the problem to the fact that the file is 32 bitdepth. Sometimes it works, and sometimes it doesn't...
The file is automatically getting pixelformat pfDevice.
If I set the pixelformat to pf8bit before loading, it seems to work, although I can't be positive about that because the problem is intermittent. It does reduce the quality of the image though...
My questions are:
1. On the same computer, why woudl it work sometimes and not others?
2. If I set to pf32bit before loading, will that work on all computers?
Thanks in advance for any insight. |
|
| Back to top |
|
 |
GrandmasterB Guest
|
Posted: Tue Sep 19, 2006 2:36 am Post subject: Re: pf32bit? |
|
|
"sduguay" <shelley.duguay (AT) maxxamanalytics (DOT) com> wrote in message
news:450f013d$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I have a bmp file which when I loadfromfile sometimes gives me the error
message 'Bitmap image is not valid.' I have traced the problem to the
fact that the file is 32 bitdepth. Sometimes it works, and sometimes it
doesn't...
|
If its working with the same image some of the time, but not all of the
time, it may not be related to the pixel format. You didnt mention what OS
you are using. If under Win9x/Me, its possible you are running out of
bitmap handles. |
|
| Back to top |
|
 |
sduguay Guest
|
Posted: Wed Sep 20, 2006 7:07 pm Post subject: Re: pf32bit? |
|
|
"GrandmasterB" <Fizzle (AT) shizzle (DOT) com> wrote:
| Quote: |
"sduguay" <shelley.duguay (AT) maxxamanalytics (DOT) com> wrote in message
news:450f013d$1 (AT) newsgroups (DOT) borland.com...
I have a bmp file which when I loadfromfile sometimes gives me the error
message 'Bitmap image is not valid.' I have traced the problem to the
fact that the file is 32 bitdepth. Sometimes it works, and sometimes it
doesn't...
If its working with the same image some of the time, but not all of the
time, it may not be related to the pixel format. You didnt mention what OS
you are using. If under Win9x/Me, its possible you are running out of
bitmap handles.
|
The OS varies, but the problem has for sure happened under WinNT/Citrix session and under WinXP Professional.
Is there a way to programatically free up bitmap handles? I am freeing the bitmap object.
Here is my code:
letterhead := TBitmap.Create;
letterhead.LoadFromFile( HeaderFileName);
TBaseReport(Sender).PrintBitMapRect( top_x1, top_y1, top_x2, top_y2, letterhead );
letterhead.Destroy;
Thanks |
|
| Back to top |
|
 |
GrandmasterB Guest
|
Posted: Wed Sep 20, 2006 11:07 pm Post subject: Re: pf32bit? |
|
|
"sduguay" <shelley.duguay (AT) maxxamanalytics (DOT) com> wrote in message
news:45114b09$1 (AT) newsgroups (DOT) borland.com...
| Quote: | The OS varies, but the problem has for sure happened under WinNT/Citrix
session and under WinXP Professional.
Is there a way to programatically free up bitmap handles? I am freeing
the bitmap object.
Here is my code:
letterhead := TBitmap.Create;
letterhead.LoadFromFile( HeaderFileName);
TBaseReport(Sender).PrintBitMapRect( top_x1, top_y1, top_x2, top_y2,
letterhead );
letterhead.Destroy;
|
hmm. What line specifically is it crashing on? A few thoughts.
- use letterhead.Free, not letterhead.destroy.
- how big is HeaderFileName? If its big (larger than the screen size in one
dimension), it might be too big for the Citrix 'video driver', and give you
an error like that. Thats an obscure kind of problem, but I've seen similar
ones from time to time.
- Are you sure top_* are all set to reasonable values?
- Are you sure HeaderFileName exists? If you're just passing a file name,
the application may have changed a working directory and made the file
unfindable. You might want to wrap everything around a
if (FileExists( HeaderFileName)) then
begin
//load from file, etc.
end |
|
| Back to top |
|
 |
sduguay Guest
|
Posted: Thu Sep 21, 2006 2:02 am Post subject: Re: pf32bit? |
|
|
"GrandmasterB" <Fizzle (AT) shizzle (DOT) com> wrote:
| Quote: | "sduguay" <shelley.duguay (AT) maxxamanalytics (DOT) com> wrote in message
news:45114b09$1 (AT) newsgroups (DOT) borland.com...
The OS varies, but the problem has for sure happened under WinNT/Citrix
session and under WinXP Professional.
Is there a way to programatically free up bitmap handles? I am freeing
the bitmap object.
Here is my code:
letterhead := TBitmap.Create;
letterhead.LoadFromFile( HeaderFileName);
TBaseReport(Sender).PrintBitMapRect( top_x1, top_y1, top_x2, top_y2,
letterhead );
letterhead.Destroy;
hmm. What line specifically is it crashing on? A few thoughts.
- use letterhead.Free, not letterhead.destroy.
- how big is HeaderFileName? If its big (larger than the screen size in one
dimension), it might be too big for the Citrix 'video driver', and give you
an error like that. Thats an obscure kind of problem, but I've seen similar
ones from time to time.
- Are you sure top_* are all set to reasonable values?
- Are you sure HeaderFileName exists? If you're just passing a file name,
the application may have changed a working directory and made the file
unfindable. You might want to wrap everything around a
if (FileExists( HeaderFileName)) then
begin
//load from file, etc.
end
|
All excellent questions... It crashes on the loadfromfile line. I just put this code in shorthand here to simplify it.. Yes the HeaderFileName exists. I agree with changing the Destroy to Free...
It works all the time when we use an 8 bit header file.., only intermittently when we use an 32 bit header file..
The size vs screen resolutionis a good idea and I'll check that, buit it works sometime sand not others on the same machine in the same citrix session.
an interesting note is that if I set the pixelformat to pf8bit before loading the header file I never get a crash... That's why I keyed in on the Pixel format, and why moy original question was about if it woudl be safe to set the pixel format to pf32bit. If this would work on all machines. |
|
| Back to top |
|
 |
GrandmasterB Guest
|
Posted: Thu Sep 21, 2006 2:26 am Post subject: Re: pf32bit? |
|
|
"sduguay" <shelley.duguay (AT) maxxamanalytics (DOT) com> wrote in message
news:4511ac55$1 (AT) newsgroups (DOT) borland.com...
| Quote: | All excellent questions... It crashes on the loadfromfile line.
|
Thats pretty odd then. I cant think of a reason it'd crash intermittantly
on the same file. Could the file be locked by another program/thread?
| Quote: | an interesting note is that if I set the pixelformat to pf8bit before
loading the header file I never get a crash...
That's why I keyed in on the Pixel format, and why moy original question
was about if it woudl be safe to
set the pixel format to pf32bit. If this would work on all machines.
|
If that fixes it, yeah, I think you'd be ok with setting it to pf32 ahead of
loading. I usually manually set that for all the bmp's I create in code
regardless of the user's color resolution to ensure its not set to pfDevice
by default. Does having it set to pf8bit affect the output at all? When
you do the loadfromfile, that should replace whatever pixel format you're
using with that of the bitmap being loaded anyways, and not affect the
display. |
|
| Back to top |
|
 |
sduguay Guest
|
Posted: Thu Sep 21, 2006 7:56 pm Post subject: Re: pf32bit? |
|
|
"GrandmasterB" <Fizzle (AT) shizzle (DOT) com> wrote:
| Quote: | "sduguay" <shelley.duguay (AT) maxxamanalytics (DOT) com> wrote in message
news:4511ac55$1 (AT) newsgroups (DOT) borland.com...
All excellent questions... It crashes on the loadfromfile line.
Thats pretty odd then. I cant think of a reason it'd crash intermittantly
on the same file. Could the file be locked by another program/thread?
an interesting note is that if I set the pixelformat to pf8bit before
loading the header file I never get a crash...
That's why I keyed in on the Pixel format, and why moy original question
was about if it woudl be safe to
set the pixel format to pf32bit. If this would work on all machines.
If that fixes it, yeah, I think you'd be ok with setting it to pf32 ahead of
loading. I usually manually set that for all the bmp's I create in code
regardless of the user's color resolution to ensure its not set to pfDevice
by default. Does having it set to pf8bit affect the output at all? When
you do the loadfromfile, that should replace whatever pixel format you're
using with that of the bitmap being loaded anyways, and not affect the
display.
|
Setting to pf8bit prior to loading works, but the quality of the image printed is reduced significantly.
Thanks for all your input. |
|
| Back to top |
|
 |
Lord Crc Guest
|
Posted: Sun Sep 24, 2006 3:34 am Post subject: Re: pf32bit? |
|
|
On 21 Sep 2006 07:56:38 -0700, "sduguay"
<shelley.duguay (AT) maxxamanalytics (DOT) com> wrote:
| Quote: | Setting to pf8bit prior to loading works, but the quality of the image printed is reduced significantly.
Thanks for all your input.
|
How large are these images, as in width / height? If they're too
large, TBitmap might barf, even on 2k/xp.
- Asbjørn |
|
| Back to top |
|
 |
sduguay Guest
|
Posted: Thu Sep 28, 2006 12:27 am Post subject: Re: pf32bit? |
|
|
"sduguay" <shelley.duguay (AT) maxxamanalytics (DOT) com> wrote:
| Quote: |
"GrandmasterB" <Fizzle (AT) shizzle (DOT) com> wrote:
"sduguay" <shelley.duguay (AT) maxxamanalytics (DOT) com> wrote in message
news:4511ac55$1 (AT) newsgroups (DOT) borland.com...
All excellent questions... It crashes on the loadfromfile line.
Thats pretty odd then. I cant think of a reason it'd crash intermittantly
on the same file. Could the file be locked by another program/thread?
an interesting note is that if I set the pixelformat to pf8bit before
loading the header file I never get a crash...
That's why I keyed in on the Pixel format, and why moy original question
was about if it woudl be safe to
set the pixel format to pf32bit. If this would work on all machines.
If that fixes it, yeah, I think you'd be ok with setting it to pf32 ahead of
loading. I usually manually set that for all the bmp's I create in code
regardless of the user's color resolution to ensure its not set to pfDevice
by default. Does having it set to pf8bit affect the output at all? When
you do the loadfromfile, that should replace whatever pixel format you're
using with that of the bitmap being loaded anyways, and not affect the
display.
Setting to pf8bit prior to loading works, but the quality of the image printed is reduced significantly.
Thanks for all your input.
|
An update on this. I changed itto set the pixelformat to pf32bit prior to calling the loadfromfile. Unfortunately, we still get the error now and then... |
|
| Back to top |
|
 |
sduguay Guest
|
Posted: Thu Sep 28, 2006 12:30 am Post subject: Re: pf32bit? |
|
|
Lord Crc <lordcrc (AT) hotmail (DOT) com> wrote:
| Quote: | On 21 Sep 2006 07:56:38 -0700, "sduguay"
shelley.duguay (AT) maxxamanalytics (DOT) com> wrote:
Setting to pf8bit prior to loading works, but the quality of the image printed is reduced significantly.
Thanks for all your input.
How large are these images, as in width / height? If they're too
large, TBitmap might barf, even on 2k/xp.
- Asbjørn
|
31.91 x 1.71 inches
or
2297 x 123 pixels
but it is being printed shrunk to about 7 inches x 0.4 inches using the PrintBitmapRect() call.
Shelley |
|
| Back to top |
|
 |
Lord Crc Guest
|
Posted: Thu Sep 28, 2006 2:39 am Post subject: Re: pf32bit? |
|
|
On 27 Sep 2006 12:30:48 -0700, "sduguay"
<shelley.duguay (AT) maxxamanalytics (DOT) com> wrote:
| Quote: | 31.91 x 1.71 inches
|
Inches is totally irrelevant ;)
This isn't big at all, except if you're on a win98 box. Have you tried
to enable debug dcu's and find out where exactly it crashes?
- Asbjørn |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|