Page 1 of 1

specifying the dimensions of output image file

Posted: Tue Nov 12, 2013 5:51 pm
by rkm
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.

Posted: Tue Nov 12, 2013 8:47 pm
by DPlotAdmin
[SetPluginImageDims(wPixels,hPixels|,option1|,option2|,option3|,option4||||)]

Online: http://www.dplot.com/help/index.htm?set ... ommand.htm

Posted: Tue Nov 12, 2013 11:50 pm
by rkm
I failed to mention I need to do this from DPlot Jr.

Posted: Wed Nov 13, 2013 1:20 am
by DPlotAdmin
The documentation is incorrect. This command is available with DPlot Jr (but not Viewer).

Posted: Wed Nov 13, 2013 1:31 pm
by rkm
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

Posted: Wed Nov 13, 2013 5:45 pm
by DPlotAdmin
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.

Posted: Wed Nov 13, 2013 9:02 pm
by rkm
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.

Posted: Wed Nov 13, 2013 10:56 pm
by DPlotAdmin
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"")]");
Am I correct in assuming that the SetPluginImageDims() should come after the DPLOT_PLOT(...) command?
Yes.

Posted: Thu Nov 14, 2013 1:49 am
by rkm
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.

Posted: Thu Nov 14, 2013 9:09 am
by DPlotAdmin
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.

Posted: Thu Nov 14, 2013 12:35 pm
by rkm
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?

Posted: Thu Nov 14, 2013 12:54 pm
by DPlotAdmin
The same as you - 3.14.1.0 dated 8/12/2010.

I'll look into updating.

Posted: Thu Nov 14, 2013 4:35 pm
by rkm
OK, whatever the problem is, is it's pretty obscure. I'll keep experimenting at this end to see what I can find.

Posted: Thu Nov 14, 2013 4:40 pm
by DPlotAdmin
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

Posted: Thu Nov 14, 2013 10:29 pm
by rkm
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!

Posted: Fri Nov 15, 2013 1:45 am
by DPlotAdmin
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!
:D

Glad you got this worked out.

Posted: Fri Nov 15, 2013 6:20 pm
by DPlotAdmin
I overlooked this earlier:
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.

does cialis work like viagra

Posted: Sat Jun 15, 2024 1:10 am
by Pefewhify
Electrophysiological assessment indicated a non localizing sciatic nerve sciatic nerve injury <a href=https://cialis.lat/discover-the-best-pr ... cialis>buy cialis online no prescription</a>