Re: Exporting a bitmap in native resolution
- To: mathgroup at smc.vnet.net
- Subject: [mg96682] Re: Exporting a bitmap in native resolution
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Fri, 20 Feb 2009 05:47:59 -0500 (EST)
- Organization: Uni Leipzig
- References: <gnj5jn$iio$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
Hi, take the data from the DensityGraphics and use ImageMatrixQ[bm_?MatrixQ] := True ImageMatrixQ[bm_?(MatrixQ[#, VectorQ] &)] := True ImageMatrixQ[_] := False MatrixToImage[data_?ImageMatrixQ] := Module[{dim, ny, nx, ch, mind, maxd, colorf}, dim = Dimensions[data]; {ny, nx} = Take[dim, 2]; If[3==Length[dim], ch = Last[dim], ch = 1 ]; colorf = Switch[ch, 1, GrayLevel, 2, GrayLevel, 3, RGBColor, 4, RGBColor ]; {mind, maxd} = {Min[#], Max[#]} &[Flatten[data]]; If[Sqrt[#.#]&[{mind,maxd}-Round[{mind,maxd}]]<$MachineEpsilon, {mind, maxd}=Round[{mind, maxd}] ]; If[Abs[maxd-mind]<$MachineEpsilon, maxd=mind+1 ]; Graphics[ Raster[ Developer`ToPackedArray[data], {{0, 0}, {nx, ny}}, {mind, maxd}, ColorFunction -> colorf ], AspectRatio -> Automatic, PlotRange -> {{0, nx}, {0, ny}}, ImageSize -> {nx, ny} ] ] the MatrixToImage[] function above. Regards Jens sibir wrote: > HI all, > first I must mention that I am still on 5.2, but I suspect the problem > is universal. I have a ListDensityPlot which I want to export as a > bitmap (e.g., png) in native resolution, that is each data point > yielding one pixel. > I tried ImageSize and ImageResolution and googled around to no avail. > Anybody figured out how to do that? > > Thanks, Martin >