473,322 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

memcpy problem

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?
Dec 24 '07 #1
3 1458
gpraghuram
1,275 Expert 1GB
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
Dec 26 '07 #2
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++?
Dec 27 '07 #3
gpraghuram
1,275 Expert 1GB
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
Dec 27 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: ronny | last post by:
Can anyone tell me why the following code works fine using an array. <snip> double xVal; // array mxArray *X = NULL; //MatLab mxArrays
5
by: manya | last post by:
Ok, it's been a while since I've done the whole memcpy stuff with C++ and I'm having a hard time remembering everything. I hope, however, that you can help me with my problem. I memcpy a...
33
by: Case | last post by:
#define SIZE 100 #define USE_MEMCPY int main(void) { char a; char b; int n; /* code 'filling' a */
6
by: myhotline | last post by:
hi all im very confused about using memcpy and i have three questions....memcpy takes a pointer to src and a pointer to dest and copies src to destination...but im very confuzed about when to...
11
by: Peter Pichler | last post by:
A colleague encountered an interesting problem. Suppose we have a C function like this: void WRITE_THING(void* addr, THING t) { memcpy(addr, &t, sizeof t); } to copy a THING to any byte...
3
by: ebrahimbandookwala | last post by:
HI everyone I am supposed to pass back a pointer to a struct from a function whos definition cannot be changed flight_t * get_item(field_t field , void * data) the problem I encounter is...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
3
by: naren | last post by:
Iam not getting the correct pros and cons of the strcpy() and memcpy() some where i read for short strings strcpy is faster and for large strings memcpy is faster.. in strcpy() there is a single...
6
by: danu | last post by:
Basically I'm trying to do here is put the uint32_t seq_num into the first 4 bytes of the buf. But every time I do this, it wouldn't get copied in to the buf at all. Can anyone point out the...
18
by: Mark | last post by:
Hi List, I want to write a function to copy some data out of a hardware buffer. The hardware can change the contents of this buffer without it being written to by my function. I want to use...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.