void PDFDocumentImage::setCurrentPage(int page) { if (!m_document) return; if (page == m_currentPage) return; if (!(page >= 0 && page < pageCount())) return; m_currentPage = page; CGPDFPageRef cgPage = CGPDFDocumentGetPage(m_document, page + 1); // get media box (guaranteed) m_mediaBox = CGPDFPageGetBoxRect(cgPage, kCGPDFMediaBox); // get crop box (not always there). if not, use media box CGRect r = CGPDFPageGetBoxRect(cgPage, kCGPDFCropBox); if (!CGRectIsEmpty(r)) m_cropBox = r; else m_cropBox = m_mediaBox; // get page rotation angle m_rotation = CGPDFPageGetRotationAngle(cgPage) * piFloat / 180.0f; // to radians }
/*********************************************************************** * macdrv_surface_flush */ static void macdrv_surface_flush(struct window_surface *window_surface) { struct macdrv_window_surface *surface = get_mac_surface(window_surface); CGRect rect; HRGN region; window_surface->funcs->lock(window_surface); TRACE("flushing %p %s bounds %s bits %p\n", surface, wine_dbgstr_rect(&surface->header.rect), wine_dbgstr_rect(&surface->bounds), surface->bits); rect = cgrect_from_rect(surface->bounds); rect = CGRectOffset(rect, surface->header.rect.left, surface->header.rect.top); if (!IsRectEmpty(&surface->bounds) && (region = CreateRectRgnIndirect(&surface->bounds))) { if (surface->drawn) { CombineRgn(surface->drawn, surface->drawn, region, RGN_OR); DeleteObject(region); } else surface->drawn = region; } update_blit_data(surface); reset_bounds(&surface->bounds); window_surface->funcs->unlock(window_surface); if (!CGRectIsEmpty(rect)) macdrv_window_needs_display(surface->window, rect); }
void PDFDocumentImage::computeBoundsForCurrentPage() { CGPDFPageRef cgPage = CGPDFDocumentGetPage(m_document.get(), 1); CGRect mediaBox = CGPDFPageGetBoxRect(cgPage, kCGPDFMediaBox); // Get crop box (not always there). If not, use media box. CGRect r = CGPDFPageGetBoxRect(cgPage, kCGPDFCropBox); if (!CGRectIsEmpty(r)) m_cropBox = r; else m_cropBox = mediaBox; m_rotationDegrees = CGPDFPageGetRotationAngle(cgPage); }
// --------------------------------------------------------------------------- // // ----------- void bToolPrintArea::fit_to_objs(bArray* arr){ bGenericGeoElement* o; bGenericStyle* style; long j; CGRect ro,rg=CGRectZero; for(long i=1;i<=arr->count();i++){ arr->get(i,&o); for(j=1;j<=_gapp->layersAccessCtx()->count();j++){ style=_gapp->layersAccessCtx()->get(j); if(!style->visible()){ continue; } if(style->gettype()==NULL){ continue; } if(style->gettype()->index()!=o->getType()){ continue; } style->rect(o,&ro); if(CGRectIsEmpty(ro)){ continue; } if(CGRectIsEmpty(rg)){ rg=ro; } else{ rg=CGRectUnion(rg,ro); } } } if(CGRectIsEmpty(rg)){ return; } _vxr=cgr2ivr(_gapp,rg); }
/*********************************************************************** * create_surface_image * * Caller must hold the surface lock. On input, *rect is the requested * image rect, relative to the window whole_rect, a.k.a. visible_rect. * On output, it's been intersected with that part backed by the surface * and is the actual size of the returned image. copy_data indicates if * the caller will keep the returned image beyond the point where the * surface bits can be guaranteed to remain valid and unchanged. If so, * the bits are copied instead of merely referenced by the image. * * IMPORTANT: This function is called from non-Wine threads, so it * must not use Win32 or Wine functions, including debug * logging. */ CGImageRef create_surface_image(void *window_surface, CGRect *rect, int copy_data) { CGImageRef cgimage = NULL; struct macdrv_window_surface *surface = get_mac_surface(window_surface); int width, height; width = surface->header.rect.right - surface->header.rect.left; height = surface->header.rect.bottom - surface->header.rect.top; *rect = CGRectIntersection(cgrect_from_rect(surface->header.rect), *rect); if (!CGRectIsEmpty(*rect)) { CGRect visrect; CGColorSpaceRef colorspace; CGDataProviderRef provider; int bytes_per_row, offset, size; CGImageAlphaInfo alphaInfo; visrect = CGRectOffset(*rect, -surface->header.rect.left, -surface->header.rect.top); colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); bytes_per_row = get_dib_stride(width, 32); offset = CGRectGetMinX(visrect) * 4 + (height - CGRectGetMaxY(visrect)) * bytes_per_row; size = min(CGRectGetHeight(visrect) * bytes_per_row, surface->info.bmiHeader.biSizeImage - offset); if (copy_data) { CFDataRef data = CFDataCreate(NULL, (UInt8*)surface->bits + offset, size); provider = CGDataProviderCreateWithCFData(data); CFRelease(data); } else provider = CGDataProviderCreateWithData(NULL, surface->bits + offset, size, NULL); alphaInfo = surface->use_alpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst; cgimage = CGImageCreate(CGRectGetWidth(visrect), CGRectGetHeight(visrect), 8, 32, bytes_per_row, colorspace, alphaInfo | kCGBitmapByteOrder32Little, provider, NULL, FALSE, kCGRenderingIntentDefault); CGDataProviderRelease(provider); CGColorSpaceRelease(colorspace); } return cgimage; }