View previous topic :: View next topic |
Author |
Message |
rkm
Joined: 21 Nov 2012 Posts: 27
|
Posted: Tue Nov 12, 2013 5:51 pm Post subject: 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. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
DPlotAdmin Site Admin
![](images/avatars/12798672406543ad048b04c.png)
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
rkm
Joined: 21 Nov 2012 Posts: 27
|
Posted: Tue Nov 12, 2013 11:50 pm Post subject: |
|
|
I failed to mention I need to do this from DPlot Jr. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
DPlotAdmin Site Admin
![](images/avatars/12798672406543ad048b04c.png)
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Wed Nov 13, 2013 1:20 am Post subject: |
|
|
The documentation is incorrect. This command is available with DPlot Jr (but not Viewer). _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
rkm
Joined: 21 Nov 2012 Posts: 27
|
Posted: Wed Nov 13, 2013 1:31 pm Post subject: |
|
|
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 |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
DPlotAdmin Site Admin
![](images/avatars/12798672406543ad048b04c.png)
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Wed Nov 13, 2013 5:45 pm Post subject: |
|
|
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. _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
rkm
Joined: 21 Nov 2012 Posts: 27
|
Posted: Wed Nov 13, 2013 9:02 pm Post subject: |
|
|
I tried [SetPluginImageDims(475,525,24,0,0)] -it made no difference.
There's no saved DPlot file, I'm using DPlot Jr. and DDE
Am I correct in assuming that the SetPluginImageDims() should come after the DPLOT_PLOT(...) command?
Other than the dimensions issue the image is being saved properly. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
DPlotAdmin Site Admin
![](images/avatars/12798672406543ad048b04c.png)
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Wed Nov 13, 2013 10:56 pm Post subject: |
|
|
Quote: | There's no saved DPlot file, I'm using DPlot Jr. and DDE |
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"")]");
Quote: | Am I correct in assuming that the SetPluginImageDims() should come after the DPLOT_PLOT(...) command? |
Yes. _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
rkm
Joined: 21 Nov 2012 Posts: 27
|
Posted: Thu Nov 14, 2013 1:49 am Post subject: |
|
|
OK I'll email you a grf and a png, of the same image, supposed to be 475x525.
In addition to the dimensions problem with the png you can see that some of the vertical lines, that appear correctly in the grf, have been left out of the png. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
DPlotAdmin Site Admin
![](images/avatars/12798672406543ad048b04c.png)
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Thu Nov 14, 2013 9:09 am Post subject: |
|
|
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. _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
rkm
Joined: 21 Nov 2012 Posts: 27
|
Posted: Thu Nov 14, 2013 12:35 pm Post subject: |
|
|
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? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
DPlotAdmin Site Admin
![](images/avatars/12798672406543ad048b04c.png)
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Thu Nov 14, 2013 12:54 pm Post subject: |
|
|
The same as you - 3.14.1.0 dated 8/12/2010.
I'll look into updating. _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
rkm
Joined: 21 Nov 2012 Posts: 27
|
Posted: Thu Nov 14, 2013 4:35 pm Post subject: |
|
|
OK, whatever the problem is, is it's pretty obscure. I'll keep experimenting at this end to see what I can find. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
DPlotAdmin Site Admin
![](images/avatars/12798672406543ad048b04c.png)
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Thu Nov 14, 2013 4:40 pm Post subject: |
|
|
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/freeimage/FreeImage3154Win32.zip _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
rkm
Joined: 21 Nov 2012 Posts: 27
|
Posted: Thu Nov 14, 2013 10:29 pm Post subject: |
|
|
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! |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
DPlotAdmin Site Admin
![](images/avatars/12798672406543ad048b04c.png)
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Fri Nov 15, 2013 1:45 am Post subject: |
|
|
Quote: | I plan to learn to write bug-free code in some future life. |
Well if I'm still around (or around again) please let me know how you did it!
Glad you got this worked out. _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
DPlotAdmin Site Admin
![](images/avatars/12798672406543ad048b04c.png)
Joined: 24 Jun 2003 Posts: 2310 Location: Vicksburg, Mississippi
|
Posted: Fri Nov 15, 2013 6:20 pm Post subject: |
|
|
I overlooked this earlier:
Quote: | I haven't yet figured out why the dimension setting was failing. |
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. _________________ Visualize Your Data
support@dplot.com |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|