Hcpy problem in CGX

Hello, I am testing a cloud application containing CGX at https://az.nuvolos.cloud/

There I came across the following strange behaviour with CGX hcpy command.

Left is the preview of the png file in vscode, to the right you see the actual cgx window.
The triad including the “s” tag is mirrored about the horizontal axis and the graphics area also seems to be mirrored, at least the title is gone and the upper margin (where the title could have gone) is cut off.

This looks the same for gif files.

The native export format of CGX seems to be tga, other formats are generated using the convert command.

Yet hcpy tga generates a file, which also isn’t correct. In Inkscape it displays like this

This means the file is still wrong and not just mis-oriented.

here is another example of a “piecewise mirrored” image:

CCX and CGX have been built from source by the nuvolos admins, the user (me) just has no access to the header file, i.e. I can’t compile

The following added info might be of help:

  • if compiled and run on a quite old virtual box (Linux machine, nodename vb, release 3.16.0-38-generic, version #52~14.04.1-Ubuntu SMP Fri May 8 09:43:57 UTC 2015, machine x86_64), the hcpy command works correct.
  • if I copy that executable from the virtual box to the nuvolos application, the problem appears again.
  • so I assume that it is not a problem on CGX code side but in some library or external tool used in the process of hardcopying, or even in the graphics interface of the system.

Has anyone encountered and possibly fixed this kind of problem? Or any idea where to dig for a solution?

Martin Kraska

Seems there is some discussion about the issue here:

And the workaround to add -auto-orient to the convert command worked for me.

[feacluster@micro src]$ grep convert *.c | grep auto
cgx.c:      sprintf( buffer, "convert -auto-orient hcpy_%d.tga -page A4 %s", psNr, fileName);
cgx.c:      sprintf( buffer, "convert -auto-orient hcpy_0.tga _%d.gif",gifNr);
cgx.c:      sprintf( buffer, "convert -auto-orient hcpy_%d.tga %s", gifNr, fileName);
cgx.c:      sprintf( buffer, "convert -auto-orient hcpy_%d.tga %s", pngNr, fileName);

Thank you for pointing to the issue. Yet, the problem is that already the tga file is wrong, As you see in the inkscape screenshot, the title is missing and the triade is wrongly placed.

The screenshot actually seems to be composed of 3 individual tga files, which are then composed into the final one. Thus, either these screenshots are already mis-oriented and mis-cropped or the call to composite is broken. I’ll have to create a modified CGX executable which does not delete the intermediate tga files.

I adapted the workaround by feacluster to solve the problem by applying “convert -auto-orient 0__.tga 0__.tga” to all three raw tga files (frame with legend, graphics area, triade).

Then the result on both test systems is correct.

I think there should be a smarter fix but for now I am fine with how it is.

in cgx.c:

	// get the orientation of the tga files right
	sprintf( buffer, "convert -auto-orient 0__.tga 0__.tga");
	system (buffer);
	sprintf( buffer, "convert -auto-orient 1__.tga 1__.tga");
	system (buffer);
	sprintf( buffer, "convert -auto-orient 2__.tga 2__.tga");
	system (buffer);