contextfreeCLI throws a GDI+ error
Moderators: MtnViewJohn, chris, mtnviewmark
contextfreeCLI throws a GDI+ error
I'm trying to get ContextFreeCLI.exe to work on a win2000 machine and I get an error when the image is being written:
==========
10 rules loaded
Generating color PNG image, variation DPJRUR...
500w x 500h pixel image.
Generating...
Rendering...
Writing 500w x 500h pixel image...
A GDI+ error occured during PNG write: Win32 Error
5 shapes
Done!
==========
Rendering and saving of pngs works fine using the windows gui.
I'm not at all familiar with Windows in any form. I'm trying to get some simulation software I've written that uses CFDG to generate images working on Windows.
Any advice on how to resolve this error?
-STH
==========
10 rules loaded
Generating color PNG image, variation DPJRUR...
500w x 500h pixel image.
Generating...
Rendering...
Writing 500w x 500h pixel image...
A GDI+ error occured during PNG write: Win32 Error
5 shapes
Done!
==========
Rendering and saving of pngs works fine using the windows gui.
I'm not at all familiar with Windows in any form. I'm trying to get some simulation software I've written that uses CFDG to generate images working on Windows.
Any advice on how to resolve this error?
-STH
- MtnViewJohn
- Site Admin
- Posts: 882
- Joined: Fri May 06, 2005 2:26 pm
- Location: Mountain View, California
- Contact:
The .cfdg file being read is in the same directory as where the .png is to be made. Since it appears to be able to read the .cfdg, I can only assume the CLI sees the destination directory as valid.
As to whether I have permission to write to that folder, I have no idea. Windows is unknown to me. I can use the gui version of ContextFree to save pngs to that directory, but I suppose that does not necessarily mean the CLI can't.
-STH
As to whether I have permission to write to that folder, I have no idea. Windows is unknown to me. I can use the gui version of ContextFree to save pngs to that directory, but I suppose that does not necessarily mean the CLI can't.
-STH
Ok. I resolved the problem I was seeing. My python code was generating weird paths. Sorry to have posted here. It was just weird to me that everything working ok on Linux and Mac OS, but not windows.
I will (hopefully) be able to share a bit of what I've been doing just so people can see how I'm using cfdg
-STH
I will (hopefully) be able to share a bit of what I've been doing just so people can see how I'm using cfdg
-STH
Re: contextfreeCLI throws a GDI+ error
I have a related problem. I'm basically trying exactly the same and having almost the same error:
The resulting PNG file is empty. I have windows 7, 64-bit, and exactly the same .bat file in the same folder with the same files in it works fine on my others computer (windows vista, 32 bit). (I just zipped the whole folder and emailed it from the computer where it worked to that where it din't work, and still it doesn't work). On another forum someone said it could be because I have another GDIPlus.dll file in my windows folder, but that isn't the case (I did a search for it, and only found the one in the contextfree folder).
Code: Select all
C:\Users\Ruben\Desktop\ContextFree\ContextFree>ContextFreeCLI input.cfdg output.
png
Reading rules file input.cfdg
15 rules loaded
Generating color PNG image, variation EBIGOF...
500w x 500h pixel image.
Generating...
Rendering...
Writing 500w x 500h pixel image...
A GDI+ error occured during PNG write: Invalid Parameter
10530 shapes
DONE!
The output file name is output.png
- MtnViewJohn
- Site Admin
- Posts: 882
- Joined: Fri May 06, 2005 2:26 pm
- Location: Mountain View, California
- Contact:
Re: contextfreeCLI throws a GDI+ error
Grrr. I know exactly what causes this and I am annoyed that I didn't fix it in the CLI build when I fixed it in the GUI build. I will put up a new CLI build tonight.
Re: contextfreeCLI throws a GDI+ error
Wow, I didn't expect a reply of this nature . Great man! I really appreciate it!
I was actually looking at the source myself, but I couldn't find out where the bug happens:
So I figured out that somewhere in the Save method of GDIPlusBitmap.h it was going wrong. But the header files don't contain the actual code for the functions, so that's where I got stuck. No idea if I was right, I don't have any substantial experience with c++.
But again, I appreciate the effort you put in this project!
I was actually looking at the source myself, but I couldn't find out where the bug happens:
Code: Select all
Status s = saveBM->Save(wpath, &encClsid, &encoderParameters);
if (s != Ok){
cerr << endl << "A GDI+ error occured during PNG write: " <<
errorMsg[s] << endl;
}
But again, I appreciate the effort you put in this project!
- MtnViewJohn
- Site Admin
- Posts: 882
- Joined: Fri May 06, 2005 2:26 pm
- Location: Mountain View, California
- Contact:
Re: contextfreeCLI throws a GDI+ error
OK. The updated Windows CLI build is in the download area.
The GDI+ png file encoder does not take any encoder parameters. So I was building an encoder parameter structure with zero parameters. This worked fine until Windows 7. With Windows 7 the png encoder fails if you provide an encoder list, even if it has zero elements. Instead you must pass a NULL pointer.
The GDI+ png file encoder does not take any encoder parameters. So I was building an encoder parameter structure with zero parameters. This worked fine until Windows 7. With Windows 7 the png encoder fails if you provide an encoder list, even if it has zero elements. Instead you must pass a NULL pointer.
Re: contextfreeCLI throws a GDI+ error
Thanks, I was able to build the commandline application myself too!
Re: contextfreeCLI throws a GDI+ error
Sorry, if I dont use width/height parameters it works fine, but when I use them, it throws a GDI+ error again...
Any idea how to fix this?
Any idea how to fix this?
Re: contextfreeCLI throws a GDI+ error
it's fine. it seems that 160x160 is the minimum size.
- MtnViewJohn
- Site Admin
- Posts: 882
- Joined: Fri May 06, 2005 2:26 pm
- Location: Mountain View, California
- Contact:
Re: contextfreeCLI throws a GDI+ error
There must be something more going on. I can create 100x100 pixel output from welcome.cfdg.
Re: contextfreeCLI throws a GDI+ error
Unfortunately, you are right. I have absolutely no idea what causes the commandline renderer to throw the GDI+ error ("invalid parameter") but it seems to occur at certain sizes. For example when I try to render this file:
named "temp0.cfdg" in a map called "temp"
And I try to run the commandline renderer with this bat file:
My output is:
This really sucks because we need to get this running for a school project. Any idea what could be the problem?
Code: Select all
startshape WELCOME rule WELCOME { MESSAGE { hue 225 sat 0.7 b 0.6 } VINEL { sat 1 hue 120 x 3 y -55 r 0 b 0.5 s 10} VINEL { flip 90 sat 1 hue 120 x 85 y -55 r 0 b 0.5 s 10}} rule MESSAGE {W { x 0 } E { x 12 } L { x 24 } C { x 34 } O { x 46 } M { x 64 } E { x 80 }} rule W {LINE { r -7 } LINE { r 7 } LINE { x 6 r -7 } LINE { x 6 r 7 }} rule E {LINE { } LINE { s 0.4 r -90 y 0 } LINE { s 0.4 r -90 y 12 } LINE { s 0.4 r -90 y 24 }} rule L {LINE { } LINE { s 0.4 x 0.4 r -90 y 0 }} rule C {ARCL { y 12 flip 90 } ARCL { y 12 r 180 }} rule O {ARCL { y 12 flip 90} ARCL { y 12 r 180 } ARCL { y 12 x 14 r 180 flip 90} ARCL { y 12 x 14 }} rule M {LINE { y 24 r 180 } LINE { y 24 r -160 s 0.75 } LINE { y 24 x 12 r 160 s 0.75 } LINE { y 24 x 12 r 180 }} rule LINE {TRIANGLE [ s 1 30 y 0.26 ]} rule ARCL {MARK { } ARCL { size 0.97 y 0.55 r 1.5 }} rule MARK {SQUARE { }} rule VINEL {STEML { } STEML { x 1 r 5 flip 0 } VINEL { x 2 size 0.9 r 10 }} rule STEML {GOL { r 20 s 0.1 } END { s 0.2 r 120 hue 150 x 1.3 y -0.6 b -0.3}} rule GOL {CIRCLE { } GOL { x 0.3 r -1 s 0.985 }} rule END {CIRCLE { x -0.5 y 0.0 s 1.0 } CIRCLE { x 0.45 y 0.6 s 0.9 } CIRCLE { x -0.4 y 1.2 s 0.8 } CIRCLE { x 0.35 y 1.8 s 0.7 } CIRCLE { x -0.3 y 2.4 s 0.6 }}
And I try to run the commandline renderer with this bat file:
Code: Select all
ContextFreeCLI /w 445 /h 414 /b 1 /x 0,3 /v XQM ./temp/temp0.cfdg ./temp/temp0.png
pause
Code: Select all
D:\Bestanden\Projecten\c#\lr2dkevolution\trunk\Evolution\bin\Debug>ContextFreeCL
I /w 445 /h 414 /b 1 /x 0,3 /v XQM ./temp/temp0.cfdg ./temp/temp0.png
Reading rules file ./temp/temp0.cfdg
15 rules loaded
Generating color PNG image, variation XQM...
445w x 414h pixel image.
Generating...
Rendering...
Writing 445w x 414h pixel image...
A GDI+ error occured during PNG write: Invalid Parameter
9464 shapes
DONE!
The output file name is ./temp/temp0.png
D:\Bestanden\Projecten\c#\lr2dkevolution\trunk\Evolution\bin\Debug>pause
Druk op een toets om door te gaan. . .
- MtnViewJohn
- Site Admin
- Posts: 882
- Joined: Fri May 06, 2005 2:26 pm
- Location: Mountain View, California
- Contact:
Re: contextfreeCLI throws a GDI+ error
OK, I found the bug. The individual rows of pixels need to be padded to a 32-bit boundary and they are not. The work-around is to set the width to a multiple of four. If you can't do this then you can force Context Free to use RGBA instead of RGB. You can do this with the code:
This tricks Context Free into using 32-bit pixels even though the background will actually still be opaque.
Code: Select all
background {a -0.001}
Re: contextfreeCLI throws a GDI+ error
great, that should help thanks!