Here I produce a Raster image with large uniformly colored rectangles and put it in an Inset:
With[{n = 5},
Graphics[Inset[
Graphics[Raster[
{Map[
List @@ ColorConvert[ColorData["LakeColors"][#],
RGBColor] &, (Range[n - 1] - 1)/(n - 2)]}
]],
Automatic, Automatic, {.45, .5}
]
]
]

Now export this to PDF:
Export["p.pdf", %]

The uniform regions have been replaced by a series of discrete bands that seem to try an interpolate between the rectangles. This happens if I choose fewer rectangles too (e.g., n = 3).
If I generate the same thing without using Raster, the exported PDF looks fine - e.g., try this:
With[{n = 5},
Graphics[Inset[
Graphics[
MapIndexed[{ColorData["LakeColors"][#],
Translate[Rectangle[], {#2[[1]], 0}]} &, (Range[n - 1] -
1)/(n - 2)]
]
,
Automatic, Automatic, {.45, .5}
]
]
]
So it's the conversion of the rasterized image in Export that's responsible for this effect. Interestingly, one can work around this (on Mac) by selecting the graphic, going to Edit > Copy As > PDF and pasting the result into Preview.
Although I have some workarounds now, it still seems mysterious to me why this banding effect happens with Raster. And it would of course be nice if someone knew how to use Raster in an Inset inside a Graphics without triggering the effect that causes the blocks of the raster to lose their uniform color.
Also - the arguments to Inset can be left out (in particular the scaling {.45, .5}). But it seemed to me that this problem didn't always happen with Raster, and that it probably has something to do with the size of the bitmap being scaled up relative to some assumed coordinate system used in Export.
PDFsource and see if I can come up with a fix along the lines of theMediaBoxreplacement I did on this page - it didn't occur to me that I'd have to revisit that in this context... – Jens Jul 10 '12 at 01:35ColorConvert[..., "CMYK"]to theGraphics[Raster[...]]expression, and the output looks fine. I want to try and see if one can do even better, though... – Jens Jul 10 '12 at 02:13Rasterobjects are exported to PDFs as images (or in a format that suggests that they are images). For images, especially smooth tone ones like photos, it does make sense to interpolate when rescaling them. So perhaps this behaviour of Preview isn't technically incorrect. But all of this is just a guess. – Szabolcs Jul 11 '12 at 07:53