bonjour,
je cherche a obtenir une image et l'écrire dans un fichier,pour cela, j'ai recuperer via un socket (fonction receiv), le hnem provenant d'un hnem=savetomemory(...), et jai envoyer hnem ssur le reseau, je le recupere a l'autre bout, masi quand je lance ce code, sa plante a tellmemory, je pênse que c'est le hnem ki ne lui plait pas, avec gdb il me dit direct erreur dans tell memory.

voir plutot le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
 
 
#include <string.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <errno.h>
#include "libudp.h"
 
#include "FreeImage.h"
 
 
 
main()
{
FILE*fp;
 
BYTE*buf=NULL;
DWORD size;
int calc=0;
FIMEMORY *hmem=NULL;
 
 
 
hmem=FreeImage_OpenMemory(0,0);
 
hmem=(FIMEMORY*)receiv(&calc); // je le cast car receiv renvoie un char*
//memcpy(&image,dest,calc);
 
// at this point, hmem contains the entire data in memory stored in fif format.
// the amount of space used by the memory is equal to file_size
long file_size = FreeImage_TellMemory(hmem);
printf("File size : %ld\n", file_size);
// its easy to load an image from memory as well
// seek to the start of the memory stream
FreeImage_SeekMemory(hmem, 0L, SEEK_SET);
// get the file type
FREE_IMAGE_FORMAT mem_fif = FreeImage_GetFileTypeFromMemory(hmem, 0);
// load an image from the memory handle
FIBITMAP *check = FreeImage_LoadFromMemory(mem_fif, hmem, 0);
// save as a regular file
FreeImage_Save(FIF_JPEG, check, "dump.jpeg", JPEG_DEFAULT);
// make sure to close the stream since FreeImage_SaveToMemory
// will cause internal memory allocations and this is the only
// way to free this allocated memory
FreeImage_CloseMemory(hmem);
FreeImage_Unload(check);
 
}
ou est mon erreur ?? je ne voit vraiment pas.
Merci.