Maurice Lombardi wrote:
Mariano Alvarez Fernandez wrote:
GrSaveContextToJpeg is a new function, the old SaveContextToJpeg lived in the addon subdir, and I didn't know if we can change it, so I had write a new one and his pair: GrLoadContextToJpeg. Can
Shouldn't this be `From' rather than `To'?
you add it to grx.pas?
OK. To check I have also written a demo program which is the exact translation to pascal of jpgtest.c In doing this I have noticed a problem in the translation of passing GrContext parameters to procedures/functions. In C they are passed as pointers. In Pascal the best solution is usually to pass them as "var" parametrers, and this had been done previously. However there is a trick in grx that when passing a NULL pointer instead of a GrContext pointer, an internal GrContext is created and/or used. This trick is very frequently used for the current context, and is done several times in the demo program. But I know no way in Pascal to pass a nil pointer as a var parameter.
Null. :-) (This was introduced for exactly this purpose.)
So either one discards this possibility or pass the parameters as pointers GrContextPtr like in C. This is not a natural way of doing in pascal but it works.
So we can do it with var parameters. However, I'm wondering if we should do it. I'm not very familiar with using contexts in GRX, but if the usual way to create them is via functions like GrCreateContext that return pointers, then there is no disadvantage in using pointers (in fact, it saves a `^'). But if there a regularly situations where you have a real GrContext variable, then it's better to use var parameters than have to use `@'.
Frank