View Single Post
  #4 (permalink)  
Old 02-22-2005, 04:25 AM
speed speed is offline
WebProWorld Veteran
 
Join Date: Aug 2003
Location: Cornwall, UK
Posts: 999
speed RepRank 2
Default

You can't open images in notepad and play with the colours etc, apart from anything else the file is a binary format.

Sticking to JPEG for a second, JPEG is a lossy compression format which basically means that there is not a 1:1 correlation between the pixels stored in the file and the original image, there are also headers etc in the image file that describe it.

If you really want to find out about JPEG go to the official site at http://www.jpeg.org
There's a C library on there somewhere that will allow you to read and write JPEG files.

PNG format is at http://www.libpng.org/pub/png/
Just Google for the bmp and other formats you want.

With the exception of the .bmp format working with the raw image data is not a trivial exercise.

Quote:
PIXEL 1 - 6 = navy blue
PIXEL 7 - 12 = yellow

Now, isn't this less codes describing the same image ?
Yep. Instead of describing each pixel one by one, I just use the first pixel and the last pixel of a colour and all the in-between pixels of that same colour with the "-". This way, less codes describe the same image.
You are describing run-length encoding (RLE) of the image data there, I think you'll find JPEG produces much smaller files although RLE tends to be lossless compression. This is also the basis for .bmp files if I remember correctly.

There was a book on image file formats you might want to look up:

Encycolpedia of Graphics File Formats
O'Reilly & Associates, Inc
ISBN: 1-56592-058-9

While creating your own format for fun this is Ok, if you build a site using a custom image format then you will loose visitors as most/all will not have the required functionality in their everyday browsers to view custom images.
Reply With Quote