Board index » delphi » Problems with JPEGs in Image component

Problems with JPEGs in Image component

Hello everyone.

I have some problems with the Image component. When I load a JPEG image, the
class mirically (?!) changes in the next line from TJPEG image to TBitmap.
Is this a bug or am I doing something wrong?

--
---

                               ///|\\\
                              /( _ _ )\
                             /(  0 0  )\
    +-----------------------oOOo-(_)-oOOo------------------------+
    | Bojan Cekrlic    ...Always look on the bright side of life |
    +------------------------------------------------------------+
    |    ICQ: 8028223, pager: 8028...@pager.mirabilis.com        |
    |  che...@bigfoot.com               bojan.cekr...@uni-lj.si  |
    |       --->    http://www.bigfoot.com/~checko/    <---      |
    +------------------------oooO--------------------------------+
                            (   )   Oooo
                             \ (    (   )
                              \_)    ) /
                                    (_/
I am

 

Re:Problems with JPEGs in Image component


In article <6o5r44$n9...@planja.arnes.si>,
  "Bojan Cekrlic" <che...@bigfoot.com> wrote:

Quote
> Hello everyone.

> I have some problems with the Image component. When I load a JPEG image, the
> class mirically (?!) changes in the next line from TJPEG image to TBitmap.
> Is this a bug or am I doing something wrong?

         What class is it that changes from TJEG to TBitmap exactly???

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Re:Problems with JPEGs in Image component


Quote
Bojan Cekrlic wrote in message <6o5r44$n9...@planja.arnes.si>...
>Hello everyone.

>I have some problems with the Image component. When I load a JPEG image,
the
>class mirically (?!) changes in the next line from TJPEG image to TBitmap.
>Is this a bug or am I doing something wrong?

Hello again. I just discovered that this doesn't happen if you create a
TPicture object and then assign it to TImage. Hope this will be helpful to
someone....

Bojan

Re:Problems with JPEGs in Image component


In article <6oarp8$64...@planja.arnes.si>,
  "Bojan Cekrlic" <che...@bigfoot.com> wrote:

Quote
> Bojan Cekrlic wrote in message <6o5r44$n9...@planja.arnes.si>...
> >Hello everyone.

> >I have some problems with the Image component. When I load a JPEG image,
> the
> >class mirically (?!) changes in the next line from TJPEG image to TBitmap.
> >Is this a bug or am I doing something wrong?

> Hello again. I just discovered that this doesn't happen if you create a
> TPicture object and then assign it to TImage. Hope this will be helpful to
> someone....

        Could you please explain what it is that doesn't happen if
you do this, and how you make it happen in the first place?
I really haven't been able to figure out what "the class[...]changes"
means.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Re:Problems with JPEGs in Image component


Quote
>>I have some problems with the Image component. When I load a JPEG image,
>the
>>class mirically (?!) changes in the next line from TJPEG image to TBitmap.
>>Is this a bug or am I doing something wrong?

>Hello again. I just discovered that this doesn't happen if you create a
>TPicture object and then assign it to TImage. Hope this will be helpful to
>someone....

I guestt I wasn't quite exact...
I'm writing a program whitch will help me catalog my pictures and in one
part I read a picture from a file to a picture object (i.e.
Image1.Picture.LoadFromFile). I had some problems and I didn't know why. I
turned on a watch on Image1.Picture.Graphic.ClassName and guess what
happened: (part of program)

1  ...
2 Image1.Picture.LoadFromFile(s);
3 Image2.Picture.Assign(Image1.Picture.Bitmap) or anything....
4 ....

Now, on finished line 2 ClassName was TJPEGImage (since I was reading a
JPEG), and on the end of line 3 the ClassName was TBitmap?!? no matter what
the 3rd line was. When I used TPicture object instead of TImage (i.e.
MyPicture.LoadFromFile) everything was just fine... ??!

Re:Problems with JPEGs in Image component


In article <6ofhe6$ca...@planja.arnes.si>,
  "Bojan Cekrlic" <che...@bigfoot.com> wrote:
[...]

Quote
> I guestt I wasn't quite exact...
> I'm writing a program whitch will help me catalog my pictures and in one
> part I read a picture from a file to a picture object (i.e.
> Image1.Picture.LoadFromFile). I had some problems and I didn't know why. I
> turned on a watch on Image1.Picture.Graphic.ClassName and guess what
> happened: (part of program)

> 1  ...
> 2 Image1.Picture.LoadFromFile(s);
> 3 Image2.Picture.Assign(Image1.Picture.Bitmap) or anything....
> 4 ....

> Now, on finished line 2 ClassName was TJPEGImage

      That's image1.etc.ClassName? Right.

Quote
> (since I was reading a
> JPEG), and on the end of line 3 the ClassName was TBitmap?!? no matter what
> the 3rd line was. When I used TPicture object instead of TImage (i.e.
> MyPicture.LoadFromFile) everything was just fine... ??!

      When I execute line 1 and then line 2 (without the "or anything....")
the classname for Image1 changes to TBitmap. ALSO the JPEG disappears,
and both images appear empty.
      Referencing the Bitmap property of a Graphic destroys any other
image that may be in there. It can't contain a JPEG _and_ a Bitmap,
you ask about the Bitmap, it says "OK, I'll contain a bitmap",
and it throws away the JPEG and inserts an empty Bitmap.

        You're not _supposed_ to use TGraphic.Bitmap unless you
_know_ the graphic actually _contains_ a bitmap. So it says in
the docs, and sure enough this would be an example why.

       Try changing line 3 to

Image2.Picture.Assign(Image1.Picture);

and see what happens. The problem is not TImage versus TPicture,
the reason one did what you expected and the other didn't is
that in the one that did what you expected you didn't reference
the Bitmap property. (At least I bet that's it.)

David C. Ullrich

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Re:Problems with JPEGs in Image component


Quote
>      Referencing the Bitmap property of a Graphic destroys any other
>image that may be in there. It can't contain a JPEG _and_ a Bitmap,
>you ask about the Bitmap, it says "OK, I'll contain a bitmap",
>and it throws away the JPEG and inserts an empty Bitmap.

>        You're not _supposed_ to use TGraphic.Bitmap unless you
>_know_ the graphic actually _contains_ a bitmap. So it says in
>the docs, and sure enough this would be an example why.

>       Try changing line 3 to

>Image2.Picture.Assign(Image1.Picture);

>and see what happens. The problem is not TImage versus TPicture,
>the reason one did what you expected and the other didn't is
>that in the one that did what you expected you didn't reference
>the Bitmap property. (At least I bet that's it.)

Well, line 3 actually wasn't a problem. Line 3 can contain anything, even
a:=b and Class would change... I don't know what was wrong. But thank you
for this anyway (some of the stuff I didn't know)...

Bojan

Re:Problems with JPEGs in Image component


In article <6oi3oa$jt...@planja.arnes.si>,
  "Bojan Cekrlic" <che...@bigfoot.com> wrote:

Quote
> >      Referencing the Bitmap property of a Graphic destroys any other
> >image that may be in there. It can't contain a JPEG _and_ a Bitmap,
> >you ask about the Bitmap, it says "OK, I'll contain a bitmap",
> >and it throws away the JPEG and inserts an empty Bitmap.

> >        You're not _supposed_ to use TGraphic.Bitmap unless you
> >_know_ the graphic actually _contains_ a bitmap. So it says in
> >the docs, and sure enough this would be an example why.

> >       Try changing line 3 to

> >Image2.Picture.Assign(Image1.Picture);

> >and see what happens. The problem is not TImage versus TPicture,
> >the reason one did what you expected and the other didn't is
> >that in the one that did what you expected you didn't reference
> >the Bitmap property. (At least I bet that's it.)

> Well, line 3 actually wasn't a problem. Line 3 can contain anything, even
> a:=b and Class would change... I don't know what was wrong. But thank you
> for this anyway (some of the stuff I didn't know)...

        Have you _tried_ it with line 3 _exactly_

Image2.Picture.Assign(Image1.Picture);

??? When I do various other things the class does change, but it
doesn't change when I do this. Just curious whether your Delphi
is the same as mine...

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Re:Problems with JPEGs in Image component


Quote
>??? When I do various other things the class does change, but it
>doesn't change when I do this. Just curious whether your Delphi
>is the same as mine...

Well, it doesn't matter, anyway, since I've solved the problem, right? It's
possible it's because of the enviromet or I don't know...

Bojan

Re:Problems with JPEGs in Image component


In article <6oiu8s$31...@planja.arnes.si>,
  "Bojan Cekrlic" <che...@bigfoot.com> wrote:

Quote
> >??? When I do various other things the class does change, but it
> >doesn't change when I do this. Just curious whether your Delphi
> >is the same as mine...

> Well, it doesn't matter, anyway, since I've solved the problem, right? It's
> possible it's because of the enviromet or I don't know...

        Is that a yes or a no? It matters to me because I want to
_understand_ how Delphi actually _works_ instead of making random
changes until my program does what I want. You say "the class
changes" with _anything_ in place of that famous line 3. I
think I understand why the class was changing, and then why
it shouldn't change with my modified line 3. It doesn't
change with my version, on my machine.

       HAVE you tried it with _exactly_ what I suggested for
line 3 or not? I've spent a little time helping you with your
problem, I'd appreciate it if you'd try this and let me know
whether "the class changes" or not. (I find the idea that
it does change very hard to believe - I find the idea that
something in the environment affects this very hard to
swallow. So if it _does_ change for you, when you use
_exactly_ what I suggested, then I'm _seriously_ misunderstanding
something - whatever it is I'd like to get it straight.
Shouldn't take long to try it.)

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Re:Problems with JPEGs in Image component


You were right.

I've must have been doing something very wrong. I don't know.
I've tried it in a different app and it works just fine. But I still
don't know what was that I was doing wrong.

Well, thank you anyway for all of your help, I really do
apreciate it.

Bojan
If replying by email change no.spam.plese to bigfoot.com.

Re:Problems with JPEGs in Image component


In article <6oiu8s$31...@planja.arnes.si>,
  "Bojan Cekrlic" <che...@bigfoot.com> wrote:

Quote
> >??? When I do various other things the class does change, but it
> >doesn't change when I do this. Just curious whether your Delphi
> >is the same as mine...

> Well, it doesn't matter, anyway, since I've solved the problem, right? It's
> possible it's because of the enviromet or I don't know...

        Is that a yes or a no? It matters to me because I want to
_understand_ how Delphi actually _works_ instead of making random
changes until my program does what I want. You say "the class
changes" with _anything_ in place of that famous line 3. I
think I understand why the class was changing, and then why
it shouldn't change with my modified line 3. It doesn't
change with my version, on my machine.

       HAVE you tried it with _exactly_ what I suggested for
line 3 or not? I've spent a little time helping you with your
problem, I'd appreciate it if you'd try this and let me know
whether "the class changes" or not. (I find the idea that
it does change very hard to believe - I find the idea that
something in the environment affects this very hard to
swallow. So if it _does_ change for you, when you use
_exactly_ what I suggested, then I'm _seriously_ misunderstanding
something - whatever it is I'd like to get it straight.
Shouldn't take long to try it.)

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Re:Problems with JPEGs in Image component


You were right.

I've must have been doing something very wrong. I don't know.
I've tried it in a different app and it works just fine. But I still
don't know what was that I was doing wrong.

Well, thank you anyway for all of your help, I really do
apreciate it.

Bojan
If replying by email change no.spam.plese to bigfoot.com.

Re:Problems with JPEGs in Image component


Quote
On Sun, 12 Jul 1998 18:33:36 GMT, ullr...@math.okstate.edu wrote:
>Mauri...@bellsouth.net wrote:
>>See http://www.demon.co.uk/mwasoft for details.

>        This is the second time I've seen someone mention
>mwasoft in regard to all this. Exactly what is it that I could
>do with mwasoft that I can't do with TJEPGImage?

The MWA JPEG Components...

...are available for Delphi 1.0, 2.0, 3.0 and C++Builder 1 and 3, and
JPEG enable the IDE for each product. One registration gets you the
source code for all five versions. You have total compatibility across
the range. Borland only provides the free JPEG for Delphi 3.0 (and
4.0, I guess).

...can use a .dll for the JPEG compression/decompression software.
This avoids getting your main .exe even fatter. One common .dll can be
used for many applications. Borland link in the .obj files straight
into your .exe. (The use of a DLL is optional.)

...provide you with two non-visual components which you can use to set
the compression and decompression properties at design-time. Borland
just provide you with another TGraphic descendant and access to
parameters is run-time only.

...include conversion of metafiles to JPEG, etc.. You have to do this
yourself with Borland.

...support easy resizing of images and metafiles before they are
compressed as JPEGs.

...provide a data aware control for saving JPEG images in database
Blob Fields.

...provide a Quick Reports 2 printable component for printing JPEG
Images straight from a database record.

All this for about $20. In my opinion, definitely worth it.

Re:Problems with JPEGs in Image component


In article <35af9421.1411...@news.mia.bellsouth.net>,

Quote
  Mauri...@bellsouth.net wrote:
> On Sun, 12 Jul 1998 18:33:36 GMT, ullr...@math.okstate.edu wrote:

> >Mauri...@bellsouth.net wrote:
> >>See http://www.demon.co.uk/mwasoft for details.

> >        This is the second time I've seen someone mention
> >mwasoft in regard to all this. Exactly what is it that I could
> >do with mwasoft that I can't do with TJEPGImage?

> The MWA JPEG Components...

> ...are available for Delphi 1.0, 2.0, 3.0 and C++Builder 1 and 3, and
> JPEG enable the IDE for each product. One registration gets you the
> source code for all five versions. You have total compatibility across
> the range. Borland only provides the free JPEG for Delphi 3.0 (and
> 4.0, I guess).

> ...can use a .dll for the JPEG compression/decompression software.
> This avoids getting your main .exe even fatter. One common .dll can be
> used for many applications. Borland link in the .obj files straight
> into your .exe. (The use of a DLL is optional.)

> ...provide you with two non-visual components which you can use to set
> the compression and decompression properties at design-time. Borland
> just provide you with another TGraphic descendant and access to
> parameters is run-time only.

> ...include conversion of metafiles to JPEG, etc.. You have to do this
> yourself with Borland.

> ...support easy resizing of images and metafiles before they are
> compressed as JPEGs.

> ...provide a data aware control for saving JPEG images in database
> Blob Fields.

> ...provide a Quick Reports 2 printable component for printing JPEG
> Images straight from a database record.

> All this for about $20. In my opinion, definitely worth it.

         Ok, thanks. Sounds definitely worth $20 for anyone who
needs any of the above (and who finds whatever non-trivial in
Delphi - some of the "you have to do it yourself" entries seem
sort of easy), I'll save my money since none of it applies
to me.

         I don't see it here, but I _thought_ this was the
thread where someone had said something about MWA opening
jpegs as jpegs instead of converting them to bitmaps - I
was curious what that meant (can't give a very precise
quote exactly because I _didn't_ know what it meant...).

         Detail: seems to me that converting metafiles
to jpegs is "wrong". (If I had to convert a metafile to
something that could be posted on a web page I think that
using a gif would be much more approproate.)

David C. Ullrich

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

Other Threads