specifying the dimensions of output image file
Moderator: DPlotAdmin
specifying the dimensions of output image file
In one application I'm creating a plot and writing it to an image file from which it can be loaded by another application. I want to specify the dimensions in pixels of the output image file to be certain it will fit comfortably in a specified window size in the second application.
There must be someplace I can specify the image dimensions but I seem to be missing it. Any help would be appreciated.
There must be someplace I can specify the image dimensions but I seem to be missing it. Any help would be appreciated.
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
[SetPluginImageDims(wPixels,hPixels|,option1|,option2|,option3|,option4||||)]
Online: http://www.dplot.com/help/index.htm?set ... ommand.htm
Online: http://www.dplot.com/help/index.htm?set ... ommand.htm
Visualize Your Data
support@dplot.com
support@dplot.com
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
The documentation is incorrect. This command is available with DPlot Jr (but not Viewer).
Visualize Your Data
support@dplot.com
support@dplot.com
Thanks for the prompt reply.
I tried the function but it does not seem to be performing as I expected:
I started by sending the DPlot_Command to set the image dimensions
[SetPluginImageDims(475,525,24)]
followed by a [FileSaveAs(...) command
The file was saved but the image dimensions were: 577,436.
I then tried changing the specified dimensions but no matter what values I set there was no change in the plot image dimensions for PNG files. I have not tried it with other file types.
-rob
I tried the function but it does not seem to be performing as I expected:
I started by sending the DPlot_Command to set the image dimensions
[SetPluginImageDims(475,525,24)]
followed by a [FileSaveAs(...) command
The file was saved but the image dimensions were: 577,436.
I then tried changing the specified dimensions but no matter what values I set there was no change in the plot image dimensions for PNG files. I have not tried it with other file types.
-rob
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
The only thing I can think of off the top of my head is the resolution is set to some value > 100 dpi. If you use [SetPluginImageDims(475,525,24,0,0)] then you might get better results.
If you've used a Size command and don't want white space to be cropped, you'll also want to use [SetImageCrop(0)] before the FileSaveAs.
If none of this helps, please send me a saved DPlot file that you're having trouble with.
If you've used a Size command and don't want white space to be cropped, you'll also want to use [SetImageCrop(0)] before the FileSaveAs.
If none of this helps, please send me a saved DPlot file that you're having trouble with.
Visualize Your Data
support@dplot.com
support@dplot.com
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
Understood, but you can still save the graph as a DPlot file, either manually in DPlot Jr or with DPlot_Command(doc,"[FileSaveAs(1,""filename.grf"")]");There's no saved DPlot file, I'm using DPlot Jr. and DDE
Yes.Am I correct in assuming that the SetPluginImageDims() should come after the DPLOT_PLOT(...) command?
Visualize Your Data
support@dplot.com
support@dplot.com
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
I don't know. Your PNG file was corrupt so I couldn't look at it, but that's probably a smaller issue. I opened your file in DPlot and ran this macro:
SetPluginImageDims(475,525,24)
FileSaveAs("Portable Network Graphics","test.png")
and I get a 475x525 PNG. Thinking this might be something odd about DPlot Jr only, I modified the C test program to include this line after the call to dPlot_Plot:
dPlot_Command(DocNum,"[SetPluginImageDims(475,525,24)][FileSaveAs(\"Portable Network Graphics\",\"test.png\")]");
and it also produces a 475x525 PNG using DPlot Jr. So I'm out of ideas for now.
SetPluginImageDims(475,525,24)
FileSaveAs("Portable Network Graphics","test.png")
and I get a 475x525 PNG. Thinking this might be something odd about DPlot Jr only, I modified the C test program to include this line after the call to dPlot_Plot:
dPlot_Command(DocNum,"[SetPluginImageDims(475,525,24)][FileSaveAs(\"Portable Network Graphics\",\"test.png\")]");
and it also produces a 475x525 PNG using DPlot Jr. So I'm out of ideas for now.
Visualize Your Data
support@dplot.com
support@dplot.com
As mentioned in my separate email, I'm suspecting the problem may be in the module that writes the PNG, perhaps FREEIMAGE.DLL or at least the version distributed with DPlot.
As you mentioned, there is at least one problem, the PNG is corrupt. This is clearly a bug -some readers will handle it, Firefox, IE and some others will not. There have been some PNG related changes in the FREEIMAGE.DLL since August 2010, the date on my DPlot supplied copy. What version are you testing with?
As you mentioned, there is at least one problem, the PNG is corrupt. This is clearly a bug -some readers will handle it, Firefox, IE and some others will not. There have been some PNG related changes in the FREEIMAGE.DLL since August 2010, the date on my DPlot supplied copy. What version are you testing with?
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
The same as you - 3.14.1.0 dated 8/12/2010.
I'll look into updating.
I'll look into updating.
Visualize Your Data
support@dplot.com
support@dplot.com
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
For what it's worth I just downloaded FreeImage v 3.15.4 and it seems to work fine without recompiling DPlot or the plugins that use it. The previous version also worked fine for me (and I presume most everyone else) so this may not mean much, but when you have time please take a look at http://downloads.sourceforge.net/freeim ... 4Win32.zip
Visualize Your Data
support@dplot.com
support@dplot.com
Problem found! It was an obscure failure to initialize an index that pointed to formats and format strings in a table. I plan to learn to write bug-free code in some future life. Anyway, the result was that the image was being saved as a WMF with an extension of PNG. The viewer that succeed in loading it recognized it as a WMF in spite of the extension. I haven't yet figured out why the dimension setting was failing. DPlot works fine, as you showed, when actually saving PNGs.
I did indeed download and try FreeImage v 3.15.4 and also found it to work with no problems so far.
Many thanks for all the help -it's the best!
I did indeed download and try FreeImage v 3.15.4 and also found it to work with no problems so far.
Many thanks for all the help -it's the best!
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
Well if I'm still around (or around again) please let me know how you did it!I plan to learn to write bug-free code in some future life.
Glad you got this worked out.
Visualize Your Data
support@dplot.com
support@dplot.com
- DPlotAdmin
- Posts: 2312
- Joined: Tue Jun 24, 2003 9:34 pm
- Location: Vicksburg, Mississippi
- Contact:
I overlooked this earlier:
It wasn't "failing" so much as being ignored. Metafiles are (practically) infinitely scalable with no loss of detail, so a resolution in pixels is pretty much meaningless. If you want to specify the dimensions of a metafile in inches, use SetMetafileDims. If you don't then DPlot will generally size the metafile to match whatever Size values you've used for the width/height of the box around the plot, and default to 6" x 4.5" total if neither is used.I haven't yet figured out why the dimension setting was failing.
Visualize Your Data
support@dplot.com
support@dplot.com