Results 1 to 6 of 6

Thread: Simple question...

  1. #1

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540

    Simple question...

    I'm creating a C++ DLL for use with VB, but since this is my first day of C++ and my 21-day tutorial (I know, I read fast ) doesn't explain it.

    I've code this piece of code:

    Code:
    void _stdcall testfunc(unsigned __int8 *source, 
            unsigned __int8 *dest, short width, short height)
    {
        int iX=1, iY=1;
    
        dest = iX * iY;
    }
    ok, there's a lot more, but this is where the problem is. If I do something like dest++ it works fine, but when I try to compile the piece of code above it says "error C2440: '=' : cannot convert from 'int' to 'unsigned __int8 *'"...

    so how do I fix it?


    And something more generally: how do I convert for example integers to longs, or strings (BStr) to integers?


    Thanks...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You're assigning through a pointer so use:
    Code:
    *dest = ...;
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Oops, sorry, didn't explain that. I'm passing a 2D array of bytes to this function (for image manipulation), so I need to move the address to get to the next item in the array.

    Just found a possible mistake, maybe I should first get the start address and add the position to that, because now I'm setting it to a fixed position, which could cause problems of the array not being at that location at all, right?


    Here's the code I've been using as a template for my DLL: http://64.23.12.52/Tutorials/GM_CPPDLL.htm
    just below 'Using arrays'...



    I realize that my explanation might seem a little confusing, so here's what I'm trying to do (just as a test, since this would be my first C++ DLL):

    I'm trying to rotate a picture by 90 degrees. To do this, I pass the function 2 2D byte arrays (which hold the picture data offcourse, one array for the source, one for the destination), and the width and height of the picture (used for calculating the number of entries in the array). For the source, I can just do source++, which moves the pointer to the next item in the array, but for the dest, I need to move it for example to the items 4, 8, 12, 3, 7, 11, which means I can't just do ++ or --. That's why I used the code iX * iY to set the position... although that would probably have to change too (2nd paragraph of this post).

    Hope this makes sense...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    In that case, you can do this funky thing:
    Code:
    dest = dest + (int)(iX * iY);
    // ... or ...
    ((__int8**)dest)[iX][iY]; // Might work...not sure :)
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    I there a way I can store the starting address somewhere, so I can just do something like "dest = start + (iX * iY)". That way I can jump back and forth trough the image, which is basically what I'm trying to do...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    __int8* pStart = dest;
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width