example of using drawjpeg in c++`

  • I'm having a very difficult time in getting wpdfDrawJPEG to work in my C++ code. I can't seem to figure out how to get the jpeg into a buffer that will work.
    Here's my code:

    HANDLE temp;
    long li=0L;
    int buflen;
    int width=506;
    int height=337;
    char junk[1025];
    char *jpg_buffer;
    unsigned long bytes_read;

    jpg_buffer=malloc(width*height);

    temp=CreateFile("test.jpg",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
    if(temp!=INVALID_HANDLE_VALUE)
    {
    SetFilePointer(temp,0L,NULL,FILE_BEGIN);
    ReadFile(temp,junk,512,&bytes_read,NULL);
    while(bytes_read>0L)
    {
    memcpy((void *)(jpg_buffer+li),junk,bytes_read);
    li=li+bytes_read;
    ReadFile(temp,junk,512,&bytes_read,NULL);
    }
    CloseHandle(temp);
    buflen=(int) li;
    }

    wpdfDrawJPEG(pdf,50,105,506,337,506,337, (void *) jpg_buffer,buflen);

    It draws nothing.