xnview wrote:Could you send me your test program?
emm.... d'you mean the source? or the executable?
here's the source:
Code: Select all
#include <stdio>
#include "libgfl.h"
void main() {
printf("hello\n");
GFL_ERROR init = gflLibraryInit();
if (GFL_NO_ERROR != init) {
printf("error: %d\n", init);
return;
}
printf("init ok\n");
gflEnableLZW(GFL_TRUE);
printf("version: %s\n", gflGetVersion());
printf("version of libformat: %s\n", gflGetVersionOfLibformat());
GFL_ERROR e1;
int tiff = gflGetFormatIndexByName("tiff");
printf("format index: %d\n", tiff);
// load picture
GFL_BITMAP *thebitmap = NULL;
GFL_LOAD_PARAMS lp1;
gflGetDefaultLoadParams(&lp1);
lp1.FormatIndex = -1;
e1 = gflLoadBitmap("DSC04034.jpg", &thebitmap, &lp1, NULL);
if (GFL_NO_ERROR != e1) {
printf("error: %d\n", e1);
} else {
GFL_SAVE_PARAMS sp1;
// save to disk
printf("saving to file\n");
gflGetDefaultSaveParams(&sp1);
sp1.FormatIndex = tiff;
sp1.Compression = GFL_LZW;
e1 = gflSaveBitmap("dsc04034.tiff", thebitmap, &sp1);
if (GFL_NO_ERROR == e1) {
printf("saved\n");
} else {
printf("error: %d\n", e1);
}
// save to mem
printf("saving to mem\n");
gflGetDefaultSaveParams(&sp1);
sp1.FormatIndex = tiff;
sp1.Compression = GFL_LZW;
unsigned char* data;
unsigned long length;
e1 = gflSaveBitmapIntoMemory(&data, &length, thebitmap, &sp1);
if (GFL_NO_ERROR == e1) {
printf("saved %d bytes\n", length);
gflMemoryFree(data);
printf("mem freed\n");
} else {
printf("error: %d\n", e1);
}
printf("freeing bitmap\n");
gflFreeBitmap(thebitmap);
printf("freed\n");
}
gflLibraryExit();
}
the result is usually sth like:
Code: Select all
hello
init ok
version: 2.67
version of libformat: 4.77
format index: 2
saving to file
saved
saving to mem
saved 11120367 bytes
mem freed
freeing bitmap
freed
i tried other formats aswell. the results are:
Code: Select all
2304 x 1728, tiff:
disk - 11106543
mem - 11120367
480 x 640, tiff:
disk - 948768
mem - 949792
480 x 640, tiff, no lzw:
disk - 922872
mem - 923896
480 x 640, jpeg:
both same sizes - 37635
png - same sizes...
Oh, I said the program crashes on:
Code: Select all
char u = data[length-1];
printf("%d\n", u);
well this time it didn't, but possibly it depends on the compiler. for this little proggy i used Borland Free CmdLine Tools but previously i was using microsoft's some kind of .NET thing to write managed wrapper for gfl...