# # This has been ported by Hiroshi Saito(hiroshi@winpg.jp) # Copyright notice of the original as below. # # * # * << Haru Free PDF Library 2.0.0 >> -- rawimage_demo.c # * # * Copyright (c) 1999-2006 Takeshi Kanno # * # * Permission to use, copy, modify, distribute and sell this software # * and its documentation for any purpose is hereby granted without fee, # * provided that the above copyright notice appear in all copies and # * that both that copyright notice and this permission notice appear # * in supporting documentation. # * It is provided "as is" without express or implied warranty. # * # * @load "pdf" # ---- # main # ---- BEGIN{ fname = "pdf_rawimage.pdf"; RAW_IMAGE_DATA = "\ \xff\xff\xff\xfe\xff\xff\xff\xfc\ \xff\xff\xff\xf8\xff\xff\xff\xf0\ \xf3\xf3\xff\xe0\xf3\xf3\xff\xc0\ \xf3\xf3\xff\x80\xf3\x33\xff\x00\ \xf3\x33\xfe\x00\xf3\x33\xfc\x00\ \xf8\x07\xf8\x00\xf8\x07\xf0\x00\ \xfc\xcf\xe0\x00\xfc\xcf\xc0\x00\ \xff\xff\x80\x00\xff\xff\x00\x00\ \xff\xfe\x00\x00\xff\xfc\x00\x00\ \xff\xf8\x0f\xe0\xff\xf0\x0f\xe0\ \xff\xe0\x0c\x30\xff\xc0\x0c\x30\ \xff\x80\x0f\xe0\xff\x00\x0f\xe0\ \xfe\x00\x0c\x30\xfc\x00\x0c\x30\ \xf8\x00\x0f\xe0\xf0\x00\x0f\xe0\ \xe0\x00\x00\x00\xc0\x00\x00\x00\ \x80\x00\x00\x00\x00\x00\x00\x00" ; pdf = HPDF_New(NULL, NULL); font = HPDF_GetFont(pdf, "Helvetica", NULL); HPDF_SetCompressionMode(pdf, HPDF_COMP_ALL); # add a new page object. page = HPDF_AddPage(pdf); HPDF_Page_SetWidth(page, 172); HPDF_Page_SetHeight(page, 80); HPDF_Page_BeginText(page); HPDF_Page_SetFontAndSize(page, font, 12); HPDF_Page_MoveTextPos(page, 20, HPDF_Page_GetHeight(page) - 10); HPDF_Page_ShowText(page, "RawImageDemo"); HPDF_Page_EndText(page); image = HPDF_LoadRawImageFromFile(pdf, "rawimage/32_32_rgb.dat", 32, 32, HPDF_CS_DEVICE_RGB); # Draw image to the canvas. (normal-mode with actual size.) HPDF_Page_DrawImage(page, image, 20, 20, 32, 32); image = HPDF_LoadRawImageFromFile(pdf, "rawimage/32_32_gray.dat", 32, 32, HPDF_CS_DEVICE_GRAY); # Draw image to the canvas. (normal-mode with actual size.) HPDF_Page_DrawImage(page, image, 70, 20, 32, 32); # load GrayScale raw-image (1bit) file from memory. image = HPDF_LoadRawImageFromMem(pdf, RAW_IMAGE_DATA, 32, 32, HPDF_CS_DEVICE_GRAY, 1); HPDF_Page_DrawImage(page, image, 120, 20, 32, 32); HPDF_SaveToFile(pdf, fname); HPDF_Free(pdf); }