From a technical perspective, what exactly is RAW and how does it differ from JPG or bitmap images? I'm not asking about the pros/cons versus another format, but rather what constitutes RAW format, how is the data stored, how does it differ from JPG (other than lack of compression), and how is it different than bitmap?
RAW is data that is extracted from the camera at an earlier stage of processing.
This allows further processing to be carried out later on a computer at will. Notably, it avoids the lossy processing steps of demosaicing, sharpening/noise reduction, and JPEG compression being permanently applied to the resulting image file before it leaves the camera.
When you take a photo:
Here's what happens when you take a photo, and at what stages of processing the RAW and JPEG images are extracted.
More about the RAW format
To create the RAW file, raw data from steps 1 to 4 above is assembled into a file format, which is usually a proprietary file format based on the TIFF format. The data is sometimes compressed using a simple lossless compression algorithm and sometimes part of it is also encrypted.
Within the RAW file, the camera embeds a whole lot of metadata, with all the information necessary to do the extra processing steps later according to the camera's settings. This includes information like what white balance, sharpening and contrast settings are selected in the camera. RAW software can then choose to follow this advice or ignore it.
The camera also embeds a small JPEG file into the RAW file, which it can then use when playing back the image in the in-camera "play" mode. This embedded JPEG adds a little to the size of RAW file but it means the camera doesn't have to apply all that processing every time the image is viewed in play mode. RAW processing software on computers largely ignores the embedded JPEG, though some software may use it for a fast preview mode or for generating fast thumbnails. It is generally a fairly low quality JPEG, good enough for previewing only.
Raw files aren't really images as such, but the data straight off of the camera's sensor. I think of it as freezing the state of the camera immediately after the exposure has finished, and bundling it up into a file, normally with some kind of lossless compression. The wikipedia article provides a fair amount of detail about the sort of thing that's recorded, but as a guide I'd say:
Bear in mind that there is no single Raw format, and all camera manufacturers are free to bundle up this sort of data in their own way. Adobe is trying to promote its DNG (Digital Negative) format, which I personally use, as a standard RAW format. A few cameras can output DNG, but most have to be converted. I do this on import into Lightroom, as one of the advantages is that it can store Lr edit data within the file, and not require xml sidecars. Another advantage of DNG is that it tends to result in smaller file sizes than native Raw files.
I would imagine that because of how most sensors are built with a Bayer filter-type design, the data from the sensor just contains levels from each photo-site on the sensor. A bitmap, for example, would have combined the RGB sites to form a single pixel.
RAW is a copy of the data from the sensor. JPEG has been refined.
A RAW file is a direct dump of the data which the camera captures.
The heart of a digital camera is a light-sensitive chip known as a sensor.
A JPEG file, on the other hand, is both a standard file format, and has had some refinement applied to the image to make it look better. These refinements include correcting for white balance and sharpenning. Also, a JPEG has typically had some compression appiled. So the process of creating a JPEG discards data which was originally present on the sensor, and which will be preserved in a RAW file.
Both a RAW file and a JPEG are kinds of bitmaps (they both represent individual pixels).
Many cameras are capable of generating both a JPEG and a RAW file for each image.
When to use each
JPEG is better if
RAW is better if
I have skipped some of the details here (see comments) in order to make the basics clear.
I think this question can better be answered by wikipedia for the most technical aspects: http://en.wikipedia.org/wiki/Raw_image_format.
In general, RAW is the exact output of the sensor. It can be compressed, or not, but the main difference between JPEG and RAW is that RAW is a loss-less format. JPEG has an 8-bit per pixel depth, while RAW can have as many bits as the sensor has. So, in order to get from RAW to JPEG you have to lose a LOT of information to get from, let's say, 12-bit per pixel to 8-bit per pixel.
RAW formats are what cameras use. After that, when you are post-processing you would use a TIF format to maintain as much information as possible. TIF is also a loss-less format and it will keep the same bit depth as RAW.
If you took a look at the image that your camera initially takes, you'd be disappointed in it. After an image is taken, the photo is run through what you can think of as post-processing within the camera to boost the color, contrast, sharpness, etc.
When you shoot in RAW you get roughly the same image as you would with JPG, but you get all the data necessary to "undo" all that in-camera post-processing so that you can do it differently yourself if you want to.
When you shoot in JPG, the camera records the data, processes the image, then deletes that "undo" data to save room on your memory card.
Or if you want to qualify in a degree in RAW and camera processing check out these videos from the Google PhotoTechEDU talk: http://www.youtube.com/watch#!v=7SuDOMhUUMg&feature=PlayList&p=F7C5C8C217CF2E13&index=1&playnext=1