memcpy problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krishnasamy
    New Member
    • Jun 2007
    • 31

    #1

    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(RotateN oneFlipX);
    memcpy(cbuffer, bitmap,size);

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

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

    What is the problem?
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    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(RotateN oneFlipX);
    memcpy(cbuffer, bitmap,size);

    FILE *fptr;
    fptr = fopen("image2.b mp","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

    Comment

    • krishnasamy
      New Member
      • Jun 2007
      • 31

      #3
      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++?

      Comment

      • gpraghuram
        Recognized Expert Top Contributor
        • Mar 2007
        • 1275

        #4
        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

        Comment

        Working...