Connecting Tech Pros Worldwide Forums | Help | Site Map

memcpy problem

Newbie
 
Join Date: Jun 2007
Posts: 31
#1: Dec 24 '07
Hi,

I have problem with copy the bitmap* to char* using memcpy.

Here I given my code,

char* cbuffer;
int size = 240000;
Bitmap *bitmap = new Bitmap(L"Image.bmp");
bitmap->Rotate(RotateNoneFlipX);
memcpy(cbuffer,bitmap,size);

FILE *fptr;
fptr = fopen("image2.bmp","wb");
fwrite(cbuffer,1,size,fptr);
fclose(fptr);

In My above code, the image2.bmp has not saving.

What is the problem?

gpraghuram's Avatar
Expert
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,258
#2: Dec 26 '07

re: memcpy problem


Quote:

Originally Posted by krishnasamy

Hi,

I have problem with copy the bitmap* to char* using memcpy.

Here I given my code,

char* cbuffer;
int size = 240000;
Bitmap *bitmap = new Bitmap(L"Image.bmp");
bitmap->Rotate(RotateNoneFlipX);
memcpy(cbuffer,bitmap,size);

FILE *fptr;
fptr = fopen("image2.bmp","wb");
fwrite(cbuffer,1,size,fptr);
fclose(fptr);

In My above code, the image2.bmp has not saving.

What is the problem?


Hi,
Is this code running fine?
Whay i am asking this is, you havent allocated any memory for the cbuffer.

Raghuram
Newbie
 
Join Date: Jun 2007
Posts: 31
#3: Dec 27 '07

re: memcpy problem


Quote:

Originally Posted by gpraghuram

Hi,
Is this code running fine?
Whay i am asking this is, you havent allocated any memory for the cbuffer.

Raghuram


Thanks for your reply.

Above code is not working proberly. Actually this code was created through DLL. I checked with my exe but the image was not creating.

How I allocated the memory to char buffer.

Is there any option in c++ or vc++?
gpraghuram's Avatar
Expert
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,258
#4: Dec 27 '07

re: memcpy problem


Quote:

Originally Posted by krishnasamy

Thanks for your reply.

Above code is not working proberly. Actually this code was created through DLL. I checked with my exe but the image was not creating.

How I allocated the memory to char buffer.

Is there any option in c++ or vc++?


Are you aware of malloc/calloc/new in C++ or in C.
You have to start reading that before using it


Raghuram
Reply


Similar C / C++ bytes