/* ** Create antialiased icons since Windows fails to do this. ** ** This works for the standard way that I compile exe's, which is to include ** a single 72 x 72 icon with them. ** */ void win_icons_from_exe(void **iconr,void **smalliconr) { char fullname[512]; char basename[256]; char appname[256]; HICON icon,smallicon,icon72; int small_dx,small_dy,icon_dx,icon_dy; HINSTANCE hinst; hinst=(HINSTANCE)win_hinstance(); win_full_exe_name(fullname); wfile_basespec(basename,fullname); wfile_newext(appname,basename,""); icon_dx = GetSystemMetrics(SM_CXICON); icon_dy = GetSystemMetrics(SM_CYICON); icon = LoadImage(hinst,appname,IMAGE_ICON,icon_dx,icon_dy,0); small_dx = GetSystemMetrics(SM_CXSMICON); small_dy = GetSystemMetrics(SM_CYSMICON); smallicon = LoadImage(hinst,appname,IMAGE_ICON,small_dx,small_dy,0); icon72 = LoadImage(hinst,appname,IMAGE_ICON,72,72,0); /* Create anti-aliased icons since Windows doesn't(!) */ if (icon72) { WILLUSBITMAP *bmp,_bmp; WILLUSBITMAP *bmpsmall,_bmpsmall; WILLUSBITMAP *bmplarge,_bmplarge; bmp=&_bmp; bmp_init(bmp); bmp->width=72; bmp->height=72; bmp->bpp=24; bmp_alloc(bmp); bmp_from_icon(bmp,icon72); bmplarge=&_bmplarge; bmp_init(bmplarge); bmp_resample(bmplarge,bmp,0.,0.,72.,72.,icon_dx,icon_dy); (*iconr)=(void *)bmp_to_icon(bmplarge,icon); DestroyIcon(icon); bmpsmall=&_bmpsmall; bmp_init(bmpsmall); bmp_resample(bmpsmall,bmp,0.,0.,72.,72.,small_dx,small_dy); (*smalliconr)=(void *)bmp_to_icon(bmpsmall,smallicon); DestroyIcon(smallicon); bmp_free(bmpsmall); bmp_free(bmplarge); bmp_free(bmp); } else { (*iconr)=(void *)icon; (*smalliconr)=(void *)smallicon; } DestroyIcon(icon72); }
/* ** src guaranteed to be 24-bit color */ void publish_marked_page(PDFFILE *mpdf,WILLUSBITMAP *src,int src_dpi) { int newdpi; WILLUSBITMAP *bmp,_bmp; #if (WILLUSDEBUGX & 9) static int count=1; char filename[256]; sprintf(filename,"outsrc%02d.png",count++); bmp_write(src,filename,stdout,100); #endif bmp=&_bmp; bmp_init(bmp); newdpi = src_dpi/2; bmp->width=src->width/2; bmp->height=src->height/2; bmp->bpp=24; bmp_alloc(bmp); bmp_resample(bmp,src,(double)0.,(double)0.,(double)src->width,(double)src->height, bmp->width,bmp->height); pdffile_add_bitmap(mpdf,bmp,newdpi,-1,1); bmp_free(bmp); }