WPCubed Product Support

example of using drawjpeg in c++`

support

Hi,

DrawBitmapFile will not decompress the JPEG and use the original JPEG data instead.

Julian

#4 ♥ 0
8.9k Views 2 users read 2 min

No, the file size did not increase. I thought that as well, but that was not the case. I can use DrawBitmap..., but I thought that DrawJpeg.. would give me a smaller file.

Thanks for your reply

#3 ♥ 0
support

Hello,

Your code looks good, did the PDF file size increase? Maybe it was at wrong position or clipped.

You can also use this function to draw the JPEG file directly:

function WPDF_DrawBitmapFile(env: pdfEnviroment; x, y, w, h: Integer; filename: PAnsiChar): Integer; stdcall;

#2 ♥ 0

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.

#1 ♥ 0