Connecting Tech Pros Worldwide Forums | Help | Site Map

What is an Image?

Peder Y
Guest
 
Posts: n/a
#1: Nov 16 '05
Surely, anyone can read it's attributes and methods...

Now, how does Image store the image data? How does it discern between
e.g. jpg, gif and bmp. Does it know it's own size, or does one need to
save it to a stream to fetch the image size?

I'm trying to save images of different formats to one single file.
When I do someImage.FromStream(), will it know all the data as before,
or will some be lost in some conversion process?

If one loops through the image _properties_, RawFormat pops up as e.g.
jpg and some long code. Can the format be retrieved from this?

Thanks!


- Peder -

Nicholas Paldino [.NET/C# MVP]
Guest
 
Posts: n/a
#2: Nov 16 '05

re: What is an Image?


Peder,

The image is saved to the stream in whatever format you wish. Because
of this, why not write some sort of marker before the image stream
indicating the type, and read that? For the dimensions, why not just use
the Size property on the image (after you load it back).


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

"Peder Y" <pyda001@ec.auckland.ac.nz> wrote in message
news:10b28c6c.0409270754.628af13e@posting.google.c om...[color=blue]
> Surely, anyone can read it's attributes and methods...
>
> Now, how does Image store the image data? How does it discern between
> e.g. jpg, gif and bmp. Does it know it's own size, or does one need to
> save it to a stream to fetch the image size?
>
> I'm trying to save images of different formats to one single file.
> When I do someImage.FromStream(), will it know all the data as before,
> or will some be lost in some conversion process?
>
> If one loops through the image _properties_, RawFormat pops up as e.g.
> jpg and some long code. Can the format be retrieved from this?
>
> Thanks!
>
>
> - Peder -[/color]


James Curran
Guest
 
Posts: n/a
#3: Nov 16 '05

re: What is an Image?


An Image, as is *everything* displayed on the screen in Windows, is a
bitmap -- when in memory.

Formats are just way of compressing it for storage on disk.

Converting *to* a bitmap should never lose information (assuming the
bitmap has a suitable large color depth). However, convert a bitmap to some
other formats (notably JPEG) can result in the loss of information. (The
idea behind JPEG is that it allows great compression of photos, by removing
information that, in theory, your eye can't discern anyway)

--
Truth,
James Curran
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
(note new day job!)
"Peder Y" <pyda001@ec.auckland.ac.nz> wrote in message
news:10b28c6c.0409270754.628af13e@posting.google.c om...[color=blue]
> Surely, anyone can read it's attributes and methods...
>
> Now, how does Image store the image data? How does it discern between
> e.g. jpg, gif and bmp. Does it know it's own size, or does one need to
> save it to a stream to fetch the image size?
>
> I'm trying to save images of different formats to one single file.
> When I do someImage.FromStream(), will it know all the data as before,
> or will some be lost in some conversion process?
>
> If one loops through the image _properties_, RawFormat pops up as e.g.
> jpg and some long code. Can the format be retrieved from this?
>
> Thanks!
>
>
> - Peder -[/color]


Peder Y
Guest
 
Posts: n/a
#4: Nov 16 '05

re: What is an Image?


hi, and thanks for answers!

So, since I'm making a kinda image viewer, my many big jpg's will turn
into a gazillion bytes in memory once loaded into an array of images?

Furthermore, loading a jpg and saving it again as a jpg will hence
result in loss of data, even without any changes made? This is
presumably because the jpg is translated into a bitmap (lossless),
which is then translated into a jpg (lossy)?

Finally, whan preserving image data to a stream and reading it back
again, why do I need to set the size? Isn't this included ing what's
read in Image.FromStream()?

Thanks!

- Peder -



"James Curran" <JamesCurran@mvps.org> wrote in message news:<OpVMF7KpEHA.1460@TK2MSFTNGP12.phx.gbl>...[color=blue]
> An Image, as is *everything* displayed on the screen in Windows, is a
> bitmap -- when in memory.
>
> Formats are just way of compressing it for storage on disk.
>
> Converting *to* a bitmap should never lose information (assuming the
> bitmap has a suitable large color depth). However, convert a bitmap to some
> other formats (notably JPEG) can result in the loss of information. (The
> idea behind JPEG is that it allows great compression of photos, by removing
> information that, in theory, your eye can't discern anyway)
>
> --
> Truth,
> James Curran
> Home: www.noveltheory.com Work: www.njtheater.com
> Blog: www.honestillusion.com Day Job: www.partsearch.com
> (note new day job!)
> "Peder Y" <pyda001@ec.auckland.ac.nz> wrote in message
> news:10b28c6c.0409270754.628af13e@posting.google.c om...[color=green]
> > Surely, anyone can read it's attributes and methods...
> >
> > Now, how does Image store the image data? How does it discern between
> > e.g. jpg, gif and bmp. Does it know it's own size, or does one need to
> > save it to a stream to fetch the image size?
> >
> > I'm trying to save images of different formats to one single file.
> > When I do someImage.FromStream(), will it know all the data as before,
> > or will some be lost in some conversion process?
> >
> > If one loops through the image _properties_, RawFormat pops up as e.g.
> > jpg and some long code. Can the format be retrieved from this?
> >
> > Thanks!
> >
> >
> > - Peder -[/color][/color]
James Curran
Guest
 
Posts: n/a
#5: Nov 16 '05

re: What is an Image?


"Peder Y" <pyda001@ec.auckland.ac.nz> wrote in message
news:10b28c6c.0409280655.7348f7c7@posting.google.c om...[color=blue]
> Furthermore, loading a jpg and saving it again as a jpg will hence
> result in loss of data, even without any changes made? This is
> presumably because the jpg is translated into a bitmap (lossless),
> which is then translated into a jpg (lossy)?[/color]

Possibly, but not necessarily. JPEG works (greatly simplified
explanation) basically by scanning the image, and when if finding to pixels
next to each other, which it figures are close enough in close that your eye
can't see the difference, it makes them the same color, which make
compression easier. Scanning data once should remove information. Scanning
the same data a second time shouldn't have any affect -- all the changes
were made in the first pass.

But, JPEG algorithms can be scaled on how aggressive they are in
combining similar colors.


--
Truth,
James Curran
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
(note new day job!)


James Curran
Guest
 
Posts: n/a
#6: Nov 16 '05

re: What is an Image?


Sometimes I don't know what happens when I type.....

James Curran wrote:[color=blue]
> Possibly, but not necessarily. JPEG works (greatly simplified
> explanation) basically by scanning the image, and when IT FINDS TWO
> pixels next to each other which it figures are close enough in COLOR
> that your eye can't see the difference, it makes them the same color,
> which make compression easier.[/color]

--
Truth,
James Curran [MVP]
www.NJTheater.com (Professional)
www.NovelTheory.com (Personal)




Peder Y
Guest
 
Posts: n/a
#7: Nov 16 '05

re: What is an Image?


Hi & thanks for answering!

I know how jpg works and have made an mpeg encoder once. I just find
it odd that the win api has no way of representing a big image without
using a gazillion bytes of memory. Sure, back in the ol' days,
compression algorithms were too processor intensive to be handeled
quickly. But now, those days are gone and a computer easily handles
mpeg, motion jpeg, divx, you name it in real time, even through
congested networks. Having a small amount of bytes in memory and
manipulating these pixelwise should still not be an issue these days
if the object had some suspend() and release() functions that would
eventually result in a recalculation of the image's frequency domain
of colors. As long as the most common operation on that very image is
to view it, this would release lots of memory in such applications,
and people wouldn't have to reinvent wheels or create workarounds like
keeping everything on disk at any given time. Maybe this is an idea
for the next api or some productive programmer wanting to make a
useful lilbrary [hint :-)]

- Peder -


"James Curran" <JamesCurran@mvps.org> wrote in message news:<eCU6wEdpEHA.3640@tk2msftngp13.phx.gbl>...[color=blue]
> Sometimes I don't know what happens when I type.....
>
> James Curran wrote:[color=green]
> > Possibly, but not necessarily. JPEG works (greatly simplified
> > explanation) basically by scanning the image, and when IT FINDS TWO
> > pixels next to each other which it figures are close enough in COLOR
> > that your eye can't see the difference, it makes them the same color,
> > which make compression easier.[/color][/color]
Closed Thread