Share

Haru Free PDF Library

Subscribe

Error loading image HPDF_LoadRawImageFromMem

  1. 2009-10-21 22:35:07 UTC

    Hi all! I apologize for my English, I use auto translator. I would like to solve the following new problem.

    Here it works

    procedure TPDF.applyimage(filename: string; x, y, w, h: HPDFREAL); type TRGB = packed record r, g, b: byte; end; var image: HPDFImage; buff: array of TCMYK; x1: integer; ff: HPDF_PBYTE; begin

    setlength(buff, 100 * 100);

    for x1 := 0 to 100 * 100 - 1 do begin buff[x1].r := 255; buff[x1].g := 0; buff[x1].b := 0; end;

    ff := @buff[0];

    image := HPDFLoadRawImageFromMem(Fpdf, ff, 100, 100, HPDFCSDEVICERGB, 8); HPDFPageDrawImage(FPage, image, x, GetActualY(y) - h, w, h); end;

    But it is not. Why?

    procedure TPDF.applyimage(filename: string; x, y, w, h: HPDFREAL); type TCMYK = packed record C,M,Y,K: byte; end; var image: HPDFImage; buff: array of TCMYK; x1: integer; ff: HPDF_PBYTE; begin

    setlength(buff, 100 * 100);

    for x1 := 0 to 100 * 100 - 1 do begin buff[x1].c := 255; buff[x1].m := 0; buff[x1].y := 0; buff[x1].k := 0; end;

    ff := @buff[0];

    image := HPDFLoadRawImageFromMem(Fpdf, ff, 100, 100, HPDFCSDEVICECMYK, 8); HPDFPageDrawImage(FPage, image, x, GetActualY(y) - h, w, h); end;

    Although the documentation is written

    HPDFLoadRawImageFromMem .................. colorspace HPDFCSDEVICEGRAY or HPDFCSDEVICERGB or HPDFCSDEVICE_CMYK is allowed.

    Help plz!

  2. 2009-10-21 22:36:43 UTC

    What formatting O_o

  3. 2009-10-22 08:12:03 UTC

    Why write in documentation what is supported HPDFCSDEVICECMYK in the function HPDFLoadRawImageFromMem. If not support ... >: 0 (

    Copy from crs

        HPDF_Image
    HPDF_Image_LoadRawImageFromMem  (HPDF_MMgr          mmgr,
                                     const HPDF_BYTE   *buf,
                                     HPDF_Xref          xref,
                                     HPDF_UINT          width,
                                     HPDF_UINT          height,
                                     HPDF_ColorSpace    color_space,
                                     HPDF_UINT          bits_per_component)
    {
        HPDF_Dict image;
        HPDF_STATUS ret = HPDF_OK;
        HPDF_UINT size;
    
        HPDF_PTRACE ((" HPDF_Image_LoadRawImageFromMem\n"));
    
        **if (color_space != HPDF_CS_DEVICE_GRAY &&
                color_space != HPDF_CS_DEVICE_RGB) {
            HPDF_SetError (mmgr->error, HPDF_INVALID_COLOR_SPACE, 0);**
            return NULL;
        }
    
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.