Hello Cesar,
"I was thinking if your libary can convert all the information in an array, and, after I manipulate this VFP array, the library rebuilds the array to send back to the memory...
Do you think using your classes I can have a gain of performance ?"
This won't work, since the VFP LCK (C library construction kit provided by the Fox team) has still the old limit of 65000 array elements.
The best thing you can do if you're after a big performance gain is writing your own FLL function, which isn't too complicated.
e.g.
the C(++) file you'll need
-----------
#include "pro_ext.h"
#ifdef __cplusplus
extern "C" {
#endif
void _fastcall AdjustImageInMemory(ParamBlk *parm)
{
// create a local pointer variable of type unsigned char*
// unsigned char is the datatype for a single byte (ranging from 0 to 255)
// the * means its a pointer variable, that is the variable presents
// not the value itself, but the memory address where this single byte is
// stored
// the pointer variable is initialized to the first parameter you've pass
// to the function, the cast ( (unsigend char*)parm.. ) is needed
// because normally these types (int to unsigned char*) are not convertable
// to each other.
// the cast "tells" the C compiler: "Hi Compiler - I know exactly what i'm
// doing, treat this integer variable as if it were an unsigned char
// pointer and don't complain :)"
unsigned char* pImage = (unsigned char*)parm->p[0].ev_long;
unsigned char nPixel;
int x = parm->p[1].ev_long, y = parm->p[2].ev_long;
// loop over each pixel and adjust it
for (int xj = 0; xj < x; xj++)
{
for (int yj = 0; yj < y; yj++)
{
// read the pixel by dereferencing the pointer
// (with * before the variable)
nPixel = *pImage;
// adjust the pixel to you needs
nPixel += 1;
// write the pixel back and increment the image pointer
// (the increment operator (++) has least precedence and is done after the
// value is written back)
*pImage++ = nPixel;
}
}
}
// tell FoxPro which functions in the FLL should be accessible
// from FoxPro itself
FoxInfo FLLFuncs[] =
{
// 3 = number of parameters
// "III" = types of parameters - 3 normal integer in this case
{"AdjustImageInMemory", (FPFI) AdjustImageInMemory, 3, "III"}
};
FoxTable _FoxTable = {
(FoxTable *)0, sizeof(FLLFuncs)/sizeof(FoxInfo), FLLFuncs
};
#ifdef __cplusplus
}
#endif
The performance of this function is quite good,
executes in about 0.016 seconds on my Athlon64 3200+
Regards
Christian
"PS: Hope to meet your team again in the finals ! :-)))"
Hope so too! this time we'll take revenge for the loss in the Confederations Cup :-)
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only