//------------------------------------------------------------------------ void CGunTurret::ReadProperties(IScriptTable *pProperties) { CItem::ReadProperties(pProperties); if(pProperties) { m_turretparams.Reset(pProperties); const char *model=0; if(GetEntityProperty("objBase", model) && model && *model) { SetGeometry(eIGS_Aux0, model); } if(GetEntityProperty("objModel", model) && model && *model) { SetGeometry(eIGS_ThirdPerson, model); } if(GetEntityProperty("objBarrel", model) && model && *model) { SetGeometry(eIGS_Aux1, model); } if(GetEntityProperty("objDestroyed", model) && model && *model) SetGeometry(eIGS_Destroyed, model); } }
int swDesktop::Init() { swMain* Main = swMain::Instance(); if(!Main){ Debug << " No main instance ??";DEND; return -1; } // Just a test!! (*Main) += sigc::mem_fun(this, &swDesktop::_CanExit); // ---------------------------------------------------- swNCurses* _n = Main->CursesInstance(); if(! _n ) { Debug << " No Curses instance ??";DEND; return -1; } SetGeometry( Rect(0,0, _n->Width(), _n->Height()) ); _wr->Clear(); _wr->Fill( Rect(0,0, _n->Width(), _n->Height()), swTAttr(7, 0, A_BOLD), ACS_CKBOARD); // ------------------------------------------------- TESTS swLabel* label = new swLabel(this,0,"desk label test"); label->SetGeometry( Rect( 0,0, Width(), 1)); String S; S << "<fgcolor yellow; strong;>Label</strong; fgcolor white;> test in desktop: my W=" << Width() << ": my H=" << Height(); (*label)<< S; Update(); return 0; }
int swDesktop::Init() { swMain* Main = swMain::Instance(); if(!Main){ Debug << " No main instance ??";DEND; return -1; } // Just a test!! (*Main) += sigc::mem_fun(this, &swDesktop::_CanExit); // ---------------------------------------------------- swNCurses* _n = Main->CursesInstance(); if(! _n ) { Debug << " No Curses instance ??";DEND; return -1; } SetGeometry( Rect(0,0, _n->Width(), _n->Height()) ); _wr->Clear(); // swText T; T << " <fgcolor red;bgcolor white; /strong;> Desktop initializecd...<fgcolor black;>Good To GO!!! <fgcolor blue;> Actual size: <fgcolor black;>" << Width() << "<fgcolor blue;>:<fgcolor black;>" << Height() << " "; T << swText::END; PStr p = T.Data(); mvaddchstr( 0, 3, p);// Height()-2, p ); delete [] p; T.ReleaseData(); Update(); return 0; }
//------------------------------------------------------------------------ void CAmmoPickup::PostInit( IGameObject * pGameObject ) { // fix for hud displaying the wrong ammo name if (!m_ammoName.empty()) { SetEntityProperty("AmmoName", m_ammoName.c_str()); SetEntityProperty("Count", m_ammoCount); } else { const char *ammoName=0; if (GetEntityProperty("AmmoName", ammoName) && ammoName && ammoName[0]) { m_ammoName=ammoName; GetEntityProperty("Count", m_ammoCount); } } if (m_modelName.empty()) { const char *model=0; if (GetEntityProperty("objModel", model) && model && model[0]) m_modelName=model; } if (!m_modelName.empty()) SetGeometry(eIGS_ThirdPerson, m_modelName.c_str()); CWeapon::PostInit(pGameObject); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % P a r s e P a g e G e o m e t r y % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ParsePageGeometry() returns a region as defined by the geometry string with % respect to the image dimensions. % % The format of the ParsePageGeometry method is: % % MagickStatusType ParsePageGeometry(const Image *image, % const char *geometry,RectangeInfo *region_info, % ExceptionInfo *exception) % % A description of each parameter follows: % % o geometry: The geometry (e.g. 100x100+10+10). % % o region_info: the region as defined by the geometry string with % respect to the image and its gravity. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickStatusType ParsePageGeometry(const Image *image, const char *geometry,RectangleInfo *region_info,ExceptionInfo *exception) { MagickStatusType flags; SetGeometry(image,region_info); if (image->page.width != 0) region_info->width=image->page.width; if (image->page.height != 0) region_info->height=image->page.height; flags=ParseAbsoluteGeometry(geometry,region_info); if (flags == NoValue) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "InvalidGeometry","`%s'",geometry); return(flags); } if ((flags & PercentValue) != 0) { region_info->width=image->columns; region_info->height=image->rows; } flags=ParseMetaGeometry(geometry,®ion_info->x,®ion_info->y, ®ion_info->width,®ion_info->height); return(flags); }
/*! \brief Load geometry (linestring HP/DPM layer) \todo Really needed? \return TRUE on success or FALSE on failure */ bool VFKFeature::LoadGeometryLineStringHP() { int id, idxId, idxHp_Id; VFKDataBlock *poDataBlockLines; VFKFeature *poLine; poDataBlockLines = (VFKDataBlock *) m_poDataBlock->GetReader()->GetDataBlock("SBP"); if (!poDataBlockLines) return FALSE; idxId = m_poDataBlock->GetPropertyIndex("ID"); idxHp_Id = poDataBlockLines->GetPropertyIndex("HP_ID"); if (idxId < 0 || idxHp_Id < 0) return FALSE; id = GetProperty(idxId)->GetValueI(); poLine = poDataBlockLines->GetFeature(idxHp_Id, id); if (!poLine || !poLine->GetGeometry()) return FALSE; SetGeometry(poLine->GetGeometry()); poDataBlockLines->ResetReading(); return TRUE; }
EBox::EBox(float x, float y, float w,float h, float marginL, float marginR, float marginU, float marginD) { _nIterIndice = 0; _minInnerWidth = 0; _minInnerHeight = 0; _lpParent = NULL; _fMaxBlend = 1; _fBlend = 1; _x = 0; _y = 0; _nNumMaximizeChild = 0; SetVerticalPolicy(VCENTER); SetHorisontalPolicy(HCENTER); SetSizePolicy(INHERIT); SetCentered(false); SetGeometry(x,y,w,h); SetMargin(marginL,marginR,marginU,marginD); _layoutType = VERTICAL; if (bg == NULL) bg = KPTK::createKGraphic(); refCount++; }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % N e w P i x e l R e g i o n I t e r a t o r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % NewPixelRegionIterator() returns a new pixel iterator. % % The format of the NewPixelRegionIterator method is: % % PixelIterator *NewPixelRegionIterator(MagickWand *wand,const ssize_t x, % const ssize_t y,const size_t width,const size_t height) % % A description of each parameter follows: % % o wand: the magick wand. % % o x,y,columns,rows: These values define the perimeter of a region of % pixels. % */ WandExport PixelIterator *NewPixelRegionIterator(MagickWand *wand, const ssize_t x,const ssize_t y,const size_t width,const size_t height) { CacheView *view; const char *quantum; ExceptionInfo *exception; Image *image; PixelIterator *iterator; size_t depth; assert(wand != (MagickWand *) NULL); depth=MAGICKCORE_QUANTUM_DEPTH; quantum=GetMagickQuantumDepth(&depth); if (depth != MAGICKCORE_QUANTUM_DEPTH) ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); if ((width == 0) || (width == 0)) ThrowWandFatalException(WandError,"ZeroRegionSize",quantum); image=GetImageFromMagickWand(wand); if (image == (Image *) NULL) return((PixelIterator *) NULL); exception=AcquireExceptionInfo(); view=AcquireVirtualCacheView(image,exception); if (view == (CacheView *) NULL) return((PixelIterator *) NULL); iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator)); if (iterator == (PixelIterator *) NULL) ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", wand->name); (void) ResetMagickMemory(iterator,0,sizeof(*iterator)); iterator->id=AcquireWandId(); (void) FormatLocaleString(iterator->name,MaxTextExtent,"%s-%.20g", PixelIteratorId,(double) iterator->id); iterator->exception=exception; iterator->view=view; SetGeometry(image,&iterator->region); iterator->region.width=width; iterator->region.height=height; iterator->region.x=x; iterator->region.y=y; iterator->pixel_wands=NewPixelWands(iterator->region.width); iterator->y=0; iterator->debug=IsEventLogging(); if (iterator->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); iterator->signature=WandSignature; return(iterator); }
/* Method: ImageList#composite_layers Purpose: Equivalent to convert's -layers composite option Notes: see mogrify.c */ VALUE ImageList_composite_layers(int argc, VALUE *argv, VALUE self) { #if defined(HAVE_COMPOSITELAYERS) volatile VALUE source_images; Image *dest, *source, *new_images; RectangleInfo geometry; CompositeOperator operator = OverCompositeOp; ExceptionInfo exception; switch (argc) { case 2: VALUE_TO_ENUM(argv[1], operator, CompositeOperator); case 1: source_images = argv[0]; break; default: rb_raise(rb_eArgError, "wrong number of arguments (expected 1 or 2, got %d)", argc); break; } // Convert ImageLists to image sequences. dest = images_from_imagelist(self); new_images = clone_imagelist(dest); rm_split(dest); source = images_from_imagelist(source_images); SetGeometry(new_images,&geometry); (void) ParseAbsoluteGeometry(new_images->geometry, &geometry); geometry.width = source->page.width != 0 ? source->page.width : source->columns; geometry.height = source->page.height != 0 ? source->page.height : source->rows; GravityAdjustGeometry(new_images->page.width != 0 ? new_images->page.width : new_images->columns , new_images->page.height != 0 ? new_images->page.height : new_images->rows , new_images->gravity, &geometry); GetExceptionInfo(&exception); CompositeLayers(new_images, operator, source, geometry.x, geometry.y, &exception); rm_split(source); rm_check_exception(&exception, new_images, DestroyOnError); (void) DestroyExceptionInfo(&exception); return rm_imagelist_from_images(new_images); #else self = self; argc = argc; argv = argv; rm_not_implemented(); return (VALUE)0; #endif }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % N e w P i x e l R e g i o n I t e r a t o r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % NewPixelRegionIterator() returns a new pixel iterator. % % The format of the NewPixelRegionIterator method is: % % PixelIterator NewPixelRegionIterator(MagickWand *wand,const long x, % const long y,const unsigned long columns,const unsigned long rows, % const MagickBooleanType modify) % % A description of each parameter follows: % % o wand: the magick wand. % % o x,y,columns,rows: These values define the perimeter of a region of % pixels. % */ WandExport PixelIterator *NewPixelRegionIterator(MagickWand *wand,const long x, const long y,const unsigned long columns,const unsigned long rows) { const char *quantum; Image *image; PixelIterator *iterator; unsigned long depth; ViewInfo *view; assert(wand != (MagickWand *) NULL); depth=MAGICKCORE_QUANTUM_DEPTH; quantum=GetMagickQuantumDepth(&depth); if (depth != MAGICKCORE_QUANTUM_DEPTH) ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); if ((columns == 0) || (rows == 0)) ThrowWandFatalException(WandError,"ZeroRegionSize",quantum); image=GetImageFromMagickWand(wand); if (image == (Image *) NULL) return((PixelIterator *) NULL); view=OpenCacheView(image); if (view == (ViewInfo *) NULL) return((PixelIterator *) NULL); iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator)); if (iterator == (PixelIterator *) NULL) ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", wand->name); (void) ResetMagickMemory(iterator,0,sizeof(*iterator)); iterator->id=AcquireWandId(); (void) FormatMagickString(iterator->name,MaxTextExtent,"%s-%lu", PixelIteratorId,iterator->id); iterator->exception=AcquireExceptionInfo(); iterator->view=view; SetGeometry(image,&iterator->region); iterator->region.width=columns; iterator->region.height=rows; iterator->region.x=x; iterator->region.y=y; iterator->pixel_wands=NewPixelWands(iterator->region.width); iterator->y=0; iterator->debug=IsEventLogging(); if (iterator->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); iterator->signature=WandSignature; return(iterator); }
FrameModifier::FrameModifier (LatticeFrame* frame, const std::string& label) : LatticeFrame(label),subFrame(frame) { LatticeFrame* oldSuperFrame = frame->SetSuperFrame(this); if(oldSuperFrame) { oldSuperFrame->ReplaceSubFrame(frame,this); } SetGeometry(frame->GetGeometry()); }
Window::Window(HWND hwnd) { SetWindowLong(hwnd, GWL_USERDATA, (LONG)this); oldProc_ = (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (LONG)Proc); hwnd_ = hwnd; TexturePool::GetInstance()->Init(this); SetHitRegionMode(HitRegionMode::kEntirely); RECT rect; GetClientRect(hwnd, &rect); SetGeometry(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); }
//------------------------------------------------------------------------ bool CItem::SetGeometryFromParams(int slot, const IItemParamsNode *geometry) { FUNCTION_PROFILER(GetISystem(), PROFILE_GAME); const char *name = geometry->GetAttribute("name"); if(!name || !name[0]) { GameWarning("Missing geometry name for loading item '%s'!", GetEntity()->GetName()); return false; } Vec3 position(0,0,0); geometry->GetAttribute("position", position); Ang3 angles(0,0,0); geometry->GetAttribute("angles", angles); float scale=1.0f; geometry->GetAttribute("scale", scale); if(slot == eIGS_FirstPerson) { const char *hand = geometry->GetAttribute("hand"); int idx = 0; if(hand && hand[0]) { if(!stricmp(hand, "right")) idx = 1; else if(!stricmp(hand, "left")) idx = 2; else { GameWarning("Invalid hand '%s' loading item '%s'!", hand, GetEntity()->GetName()); return false; } } m_fpgeometry[idx].name=name; m_fpgeometry[idx].position=position; m_fpgeometry[idx].angles=DEG2RAD(angles); m_fpgeometry[idx].scale=scale; // marcio: first person geometry will be loaded upon selecting the weapon in first person //if (((idx<2) && (m_stats.hand == eIH_Right)) || ((idx==2) && (m_stats.hand == eIH_Left))) // SetGeometry(slot, name, position, DEG2RAD(angles), scale, false); } else SetGeometry(slot, name, position, DEG2RAD(angles), scale, false); return true; }
void CWidget::resizeEvent(QResizeEvent * event){/* if (iPixmap) delete iPixmap; iPixmap = new QPixmap(event->size().width(),event->size().height()); setPixmap(*iPixmap); if (CWorkspaceManager::GetInstance()) CWorkspaceManager::GetInstance()->GetActiveWorkspace()->resizeEvent(QSize(event->size().width()*4/5,event->size().height()*4/5)); *//* QPointF imageExplorerPos(this->width()*4/5,0); QPointF imageExplorerSize(this->width()*1/5,this->height()*4/5); paint(); */ SetGeometry(0,0,event->size().width(),event->size().height()); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % N e w P i x e l I t e r a t o r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % NewPixelIterator() returns a new pixel iterator. % % The format of the NewPixelIterator method is: % % PixelIterator *NewPixelIterator(MagickWand *wand) % % A description of each parameter follows: % % o wand: the magick wand. % */ WandExport PixelIterator *NewPixelIterator(MagickWand *wand) { const char *quantum; Image *image; PixelIterator *iterator; size_t depth; CacheView *view; depth=MAGICKCORE_QUANTUM_DEPTH; quantum=GetMagickQuantumDepth(&depth); if (depth != MAGICKCORE_QUANTUM_DEPTH) ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); assert(wand != (MagickWand *) NULL); image=GetImageFromMagickWand(wand); if (image == (Image *) NULL) return((PixelIterator *) NULL); view=AcquireCacheView(image); if (view == (CacheView *) NULL) return((PixelIterator *) NULL); iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator)); if (iterator == (PixelIterator *) NULL) ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", GetExceptionMessage(errno)); (void) ResetMagickMemory(iterator,0,sizeof(*iterator)); iterator->id=AcquireWandId(); (void) FormatMagickString(iterator->name,MaxTextExtent,"%s-%.20g", PixelIteratorId,(double) iterator->id); iterator->exception=AcquireExceptionInfo(); iterator->view=view; SetGeometry(image,&iterator->region); iterator->region.width=image->columns; iterator->region.height=image->rows; iterator->region.x=0; iterator->region.y=0; iterator->pixel_wands=NewPixelWands(iterator->region.width); iterator->y=0; iterator->debug=IsEventLogging(); if (iterator->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); iterator->signature=WandSignature; return(iterator); }
//------------------------------------------------------------------------ void CItem::SetViewMode(int mode) { m_stats.viewmode = mode; if(mode & eIVM_FirstPerson) { SetHand(m_stats.hand); if(!m_parentId) { uint32 flags = GetEntity()->GetFlags(); if(!m_stats.mounted) flags &= ~ENTITY_FLAG_CASTSHADOW; else flags |= ENTITY_FLAG_CASTSHADOW; //GetEntity()->SetFlags(flags|ENTITY_FLAG_RECVSHADOW); DrawSlot(eIGS_FirstPerson, true, !m_stats.mounted); } else DrawSlot(eIGS_FirstPerson, false, false); } else { SetGeometry(eIGS_FirstPerson, 0); } if(mode & eIVM_ThirdPerson) { DrawSlot(eIGS_ThirdPerson, true); if(!m_stats.mounted) CopyRenderFlags(GetOwner()); } else DrawSlot(eIGS_ThirdPerson, false); for(TAccessoryMap::iterator it = m_accessories.begin(); it != m_accessories.end(); it++) { IItem *pItem = m_pGameFramework->GetIItemSystem()->GetItem(it->second); if(pItem) { CItem *pCItem = static_cast<CItem *>(pItem); if(pCItem) pCItem->SetViewMode(mode); } } }
/*! \brief Load geometry (linestring SBP layer) \todo Really needed? \return TRUE on success or FALSE on failure */ bool VFKFeature::LoadGeometryLineStringSBP() { int id, idxId, idxBp_Id, idxPCB, ipcb; VFKDataBlock *poDataBlockPoints; VFKFeature *poPoint, *poLine; OGRLineString OGRLine; poDataBlockPoints = (VFKDataBlock *) m_poDataBlock->GetReader()->GetDataBlock("SOBR"); if (!poDataBlockPoints) return FALSE; idxId = poDataBlockPoints->GetPropertyIndex("ID"); idxBp_Id = m_poDataBlock->GetPropertyIndex("BP_ID"); idxPCB = m_poDataBlock->GetPropertyIndex("PORADOVE_CISLO_BODU"); if (idxId < 0 || idxBp_Id < 0 || idxPCB < 0) return false; poLine = this; while (TRUE) { id = poLine->GetProperty(idxBp_Id)->GetValueI(); ipcb = poLine->GetProperty(idxPCB)->GetValueI(); if (OGRLine.getNumPoints() > 0 && ipcb == 1) { m_poDataBlock->GetPreviousFeature(); /* push back */ break; } poPoint = poDataBlockPoints->GetFeature(idxId, id); if (!poPoint) { continue; } OGRPoint *pt = (OGRPoint *) poPoint->GetGeometry(); OGRLine.addPoint(pt); poLine = (VFKFeature *) m_poDataBlock->GetNextFeature(); if (!poLine) break; }; OGRLine.setCoordinateDimension(2); /* force 2D */ SetGeometry(&OGRLine); /* reset reading */ poDataBlockPoints->ResetReading(); return TRUE; }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % P a r s e R e g i o n G e o m e t r y % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ParseRegionGeometry() returns a region as defined by the geometry string % with respect to the image dimensions and aspect ratio. % % The format of the ParseRegionGeometry method is: % % MagickStatusType ParseRegionGeometry(const Image *image, % const char *geometry,RectangeInfo *region_info, % ExceptionInfo *exception) % % A description of each parameter follows: % % o geometry: The geometry (e.g. 100x100+10+10). % % o region_info: the region as defined by the geometry string. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickStatusType ParseRegionGeometry(const Image *image, const char *geometry,RectangleInfo *region_info,ExceptionInfo *exception) { MagickStatusType flags; SetGeometry(image,region_info); flags=ParseMetaGeometry(geometry,®ion_info->x,®ion_info->y, ®ion_info->width,®ion_info->height); if (flags == NoValue) (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "InvalidGeometry","`%s'",geometry); return(flags); }
/** * Equivalent to convert's -layers composite option. * * Ruby usage: * - @verbatim ImageList#composite_layers(images) @endverbatim * - @verbatim ImageList#composite_layers(images,operator) @endverbatim * * Notes: * - Default operator is OverCompositeOp * * @param argc number of input arguments * @param argv array of input arguments * @param self this object * @return a new imagelist * @see mogrify.c in ImageMagick */ VALUE ImageList_composite_layers(int argc, VALUE *argv, VALUE self) { VALUE source_images; Image *dest, *source, *new_images; RectangleInfo geometry; CompositeOperator operator = OverCompositeOp; ExceptionInfo *exception; switch (argc) { case 2: VALUE_TO_ENUM(argv[1], operator, CompositeOperator); case 1: source_images = argv[0]; break; default: rb_raise(rb_eArgError, "wrong number of arguments (expected 1 or 2, got %d)", argc); break; } // Convert ImageLists to image sequences. dest = images_from_imagelist(self); new_images = clone_imagelist(dest); rm_split(dest); source = images_from_imagelist(source_images); SetGeometry(new_images,&geometry); (void) ParseAbsoluteGeometry(new_images->geometry, &geometry); geometry.width = source->page.width != 0 ? source->page.width : source->columns; geometry.height = source->page.height != 0 ? source->page.height : source->rows; GravityAdjustGeometry(new_images->page.width != 0 ? new_images->page.width : new_images->columns , new_images->page.height != 0 ? new_images->page.height : new_images->rows , new_images->gravity, &geometry); exception = AcquireExceptionInfo(); CompositeLayers(new_images, operator, source, geometry.x, geometry.y, exception); rm_split(source); rm_check_exception(exception, new_images, DestroyOnError); (void) DestroyExceptionInfo(exception); RB_GC_GUARD(source_images); return rm_imagelist_from_images(new_images); }
/*! \brief Load geometry (point layers) \todo Really needed? \return TRUE on success \return FALSE on failure */ bool VFKFeature::LoadGeometryPoint() { double x, y; int i_idxX, i_idxY; i_idxY = m_poDataBlock->GetPropertyIndex("SOURADNICE_Y"); i_idxX = m_poDataBlock->GetPropertyIndex("SOURADNICE_X"); if (i_idxY < 0 || i_idxX < 0) return FALSE; x = -1.0 * GetProperty(i_idxY)->GetValueD(); y = -1.0 * GetProperty(i_idxX)->GetValueD(); OGRPoint pt(x, y); SetGeometry(&pt); return TRUE; }
//------------------------------------------------------------------------ void CAmmoPickup::Reset() { const char *ammoName=0; if (GetEntityProperty("AmmoName", ammoName) && ammoName && ammoName[0]) { m_ammoName=ammoName; GetEntityProperty("Count", m_ammoCount); } const char *model=0; if (GetEntityProperty("objModel", model) && model && model[0]) m_modelName=model; CWeapon::Reset(); if (!m_modelName.empty()) SetGeometry(eIGS_ThirdPerson, m_modelName.c_str()); }
CWidget::CWidget(QWidget *parent){ resize(500,500); SetGeometry(0,0,500,500); QPointF workspaceExplorerPos(0,this->height()-Settings::imageExplorerSize); QPointF workspaceExplorerSize(this->width(),Settings::imageExplorerSize); iWorkspaceExplorer = CWorkspaceExplorer::InitInstance(this, workspaceExplorerPos,workspaceExplorerSize); CWorkspaceManager::InitInstance(this); CWorkspace *workspace = new CWorkspace(this,QPointF(0,0),QPointF(this->width()-Settings::imageExplorerSize,this->height()-Settings::imageExplorerSize)); //CWorkspaceManager::GetInstance()->SetActiveWorkspace(workspace); CWorkspaceManager::GetInstance()->AddWorkspace(workspace); QPointF imageExplorerPos(this->width()-Settings::imageExplorerSize,0); QPointF imageExplorerSize(150,this->height()-Settings::imageExplorerSize); CImageExplorer::InitInstance(this, imageExplorerPos,imageExplorerSize); iImageExplorer = CImageExplorer::GetInstance(); LoadIcons(); iActiveObject=NULL; }
ItemsDisplayWindow::ItemsDisplayWindow( Widget* pWin, Rect rcClient ) : Panel(pWin) { m_imgBk = new CxImage; m_imgBk->Load("..\\res\\bg.bmp",CXIMAGE_FORMAT_BMP); SetGeometry(rcClient); SetBkCenterImage(m_imgBk); Rect rect(5,7,155,30); HFONT hfont = CreateFont(14, 0, 0, 0, FW_BOLD, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T("宋体")); m_pPathLabel = new Label(this); m_pPathLabel->SetGeometry(rect); m_pPathLabel->SetTextColor(RGB(2,121,161)); m_pPathLabel->SetFont(hfont); m_pPathLabel->SetText(_T("游戏商城 > 全部道具")); rect.y = rect.GetBottom() + 2; rect.height = 107; for (int i = 0; i < 9; i++) { m_pItemwidget[i] = new ItemDisplayWidget(this); if (i > 0 && i % 3 == 0) { rect.x = 5; rect.y = rect.GetBottom() + 5; rect.height = 109; } rect.width = 219; m_pItemwidget[i]->SetGeometry(rect); rect.x = rect.GetRight() + 6; } }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % W r i t e H T M L I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % WriteHTMLImage() writes an image in the HTML encoded image format. % % The format of the WriteHTMLImage method is: % % MagickBooleanType WriteHTMLImage(const ImageInfo *image_info,Image *image) % % A description of each parameter follows. % % o image_info: the image info. % % o image: The image. % % */ static MagickBooleanType WriteHTMLImage(const ImageInfo *image_info, Image *image) { char basename[MaxTextExtent], buffer[MaxTextExtent], filename[MaxTextExtent], mapname[MaxTextExtent], url[MaxTextExtent]; Image *next; ImageInfo *write_info; MagickBooleanType status; RectangleInfo geometry; register char *p; /* Open image. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); if (status == MagickFalse) return(status); (void) CloseBlob(image); if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) (void) TransformImageColorspace(image,sRGBColorspace); *url='\0'; if ((LocaleCompare(image_info->magick,"FTP") == 0) || (LocaleCompare(image_info->magick,"HTTP") == 0)) { /* Extract URL base from filename. */ p=strrchr(image->filename,'/'); if (p != (char *) NULL) { p++; (void) CopyMagickString(url,image_info->magick,MaxTextExtent); (void) ConcatenateMagickString(url,":",MaxTextExtent); url[strlen(url)+p-image->filename]='\0'; (void) ConcatenateMagickString(url,image->filename, p-image->filename+2); (void) CopyMagickString(image->filename,p,MaxTextExtent); } } /* Refer to image map file. */ (void) CopyMagickString(filename,image->filename,MaxTextExtent); AppendImageFormat("map",filename); GetPathComponent(filename,BasePath,basename); (void) CopyMagickString(mapname,basename,MaxTextExtent); (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent); (void) CopyMagickString(filename,image->filename,MaxTextExtent); write_info=CloneImageInfo(image_info); write_info->adjoin=MagickTrue; status=MagickTrue; if (LocaleCompare(image_info->magick,"SHTML") != 0) { const char *value; /* Open output image file. */ status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); if (status == MagickFalse) return(status); /* Write the HTML image file. */ (void) WriteBlobString(image,"<?xml version=\"1.0\" " "encoding=\"US-ASCII\"?>\n"); (void) WriteBlobString(image,"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML " "1.0 Strict//EN\" " "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"); (void) WriteBlobString(image,"<html>\n"); (void) WriteBlobString(image,"<head>\n"); value=GetImageProperty(image,"label"); if (value != (const char *) NULL) (void) FormatLocaleString(buffer,MaxTextExtent,"<title>%s</title>\n", value); else { GetPathComponent(filename,BasePath,basename); (void) FormatLocaleString(buffer,MaxTextExtent, "<title>%s</title>\n",basename); } (void) WriteBlobString(image,buffer); (void) WriteBlobString(image,"</head>\n"); (void) WriteBlobString(image,"<body style=\"text-align: center;\">\n"); (void) FormatLocaleString(buffer,MaxTextExtent,"<h1>%s</h1>\n", image->filename); (void) WriteBlobString(image,buffer); (void) WriteBlobString(image,"<div>\n"); (void) CopyMagickString(filename,image->filename,MaxTextExtent); AppendImageFormat("png",filename); (void) FormatLocaleString(buffer,MaxTextExtent,"<img usemap=\"#%s\" " "src=\"%s\" style=\"border: 0;\" alt=\"Image map\" />\n",mapname, filename); (void) WriteBlobString(image,buffer); /* Determine the size and location of each image tile. */ SetGeometry(image,&geometry); if (image->montage != (char *) NULL) (void) ParseAbsoluteGeometry(image->montage,&geometry); /* Write an image map. */ (void) FormatLocaleString(buffer,MaxTextExtent, "<map id=\"%s\" name=\"%s\">\n",mapname,mapname); (void) WriteBlobString(image,buffer); (void) FormatLocaleString(buffer,MaxTextExtent," <area href=\"%s",url); (void) WriteBlobString(image,buffer); if (image->directory == (char *) NULL) { (void) FormatLocaleString(buffer,MaxTextExtent, "%s\" shape=\"rect\" coords=\"0,0,%.20g,%.20g\" alt=\"\" />\n", image->filename,(double) geometry.width-1,(double) geometry.height- 1); (void) WriteBlobString(image,buffer); } else for (p=image->directory; *p != '\0'; p++) if (*p != '\n') (void) WriteBlobByte(image,(unsigned char) *p); else { (void) FormatLocaleString(buffer,MaxTextExtent,"\" shape=" "\"rect\" coords=\"%.20g,%.20g,%.20g,%.20g\" alt=\"\" />\n", (double) geometry.x,(double) geometry.y,(double) (geometry.x+ geometry.width-1),(double) (geometry.y+geometry.height-1)); (void) WriteBlobString(image,buffer); if (*(p+1) != '\0') { (void) FormatLocaleString(buffer,MaxTextExtent, " <area href=%s\"",url); (void) WriteBlobString(image,buffer); } geometry.x+=(ssize_t) geometry.width; if ((geometry.x+4) >= (ssize_t) image->columns) { geometry.x=0; geometry.y+=(ssize_t) geometry.height; } } (void) WriteBlobString(image,"</map>\n"); (void) CopyMagickString(filename,image->filename,MaxTextExtent); (void) WriteBlobString(image,"</div>\n"); (void) WriteBlobString(image,"</body>\n"); (void) WriteBlobString(image,"</html>\n"); (void) CloseBlob(image); /* Write the image as PNG. */ (void) CopyMagickString(image->filename,filename,MaxTextExtent); AppendImageFormat("png",image->filename); next=GetNextImageInList(image); image->next=NewImageList(); (void) CopyMagickString(image->magick,"PNG",MaxTextExtent); (void) WriteImage(write_info,image); image->next=next; /* Determine image map filename. */ GetPathComponent(image->filename,BasePath,filename); (void) ConcatenateMagickString(filename,"_map.shtml",MaxTextExtent); (void) CopyMagickString(image->filename,filename,MaxTextExtent); } /* Open image map. */ status=OpenBlob(write_info,image,WriteBinaryBlobMode,&image->exception); if (status == MagickFalse) return(status); write_info=DestroyImageInfo(write_info); /* Determine the size and location of each image tile. */ SetGeometry(image,&geometry); if (image->montage != (char *) NULL) (void) ParseAbsoluteGeometry(image->montage,&geometry); /* Write an image map. */ (void) FormatLocaleString(buffer,MaxTextExtent, "<map id=\"%s\" name=\"%s\">\n",mapname,mapname); (void) WriteBlobString(image,buffer); (void) FormatLocaleString(buffer,MaxTextExtent," <area href=\"%s",url); (void) WriteBlobString(image,buffer); if (image->directory == (char *) NULL) { (void) FormatLocaleString(buffer,MaxTextExtent, "%s\" shape=\"rect\" coords=\"0,0,%.20g,%.20g\" alt=\"\" />\n", image->filename,(double) geometry.width-1,(double) geometry.height-1); (void) WriteBlobString(image,buffer); } else for (p=image->directory; *p != '\0'; p++) if (*p != '\n') (void) WriteBlobByte(image,(unsigned char) *p); else { (void) FormatLocaleString(buffer,MaxTextExtent,"\" shape=\"rect\"" " coords=\"%.20g,%.20g,%.20g,%.20g\" alt=\"\" />\n", (double) geometry.x,(double) geometry.y,geometry.x+(double) geometry.width-1,geometry.y+(double) geometry.height-1); (void) WriteBlobString(image,buffer); if (*(p+1) != '\0') { (void) FormatLocaleString(buffer,MaxTextExtent, " <area href=%s\"",url); (void) WriteBlobString(image,buffer); } geometry.x+=(ssize_t) geometry.width; if ((geometry.x+4) >= (ssize_t) image->columns) { geometry.x=0; geometry.y+=(ssize_t) geometry.height; } } (void) WriteBlobString(image,"</map>\n"); (void) CloseBlob(image); (void) CopyMagickString(image->filename,filename,MaxTextExtent); return(status); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d V I D I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ReadVIDImage reads one of more images and creates a Visual Image % Directory file. It allocates the memory necessary for the new Image % structure and returns a pointer to the new image. % % The format of the ReadVIDImage method is: % % Image *ReadVIDImage(const ImageInfo *image_info,ExceptionInfo *exception) % % A description of each parameter follows: % % o image_info: the image info. % % o exception: return any errors or warnings in this structure. % */ static Image *ReadVIDImage(const ImageInfo *image_info,ExceptionInfo *exception) { #define ClientName "montage" char **filelist, *label; Image *image, *images, *montage_image, *next_image, *thumbnail_image; ImageInfo *read_info; int number_files; MagickBooleanType status; MontageInfo *montage_info; RectangleInfo geometry; register ssize_t i; /* Expand the filename. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image=AcquireImage(image_info); filelist=(char **) AcquireAlignedMemory(1,sizeof(*filelist)); if (filelist == (char **) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); filelist[0]=ConstantString(image_info->filename); number_files=1; status=ExpandFilenames(&number_files,&filelist); if ((status == MagickFalse) || (number_files == 0)) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); image=DestroyImage(image); /* Read each image and convert them to a tile. */ images=NewImageList(); read_info=CloneImageInfo(image_info); SetImageInfoBlob(read_info,(void *) NULL,0); (void) SetImageInfoProgressMonitor(read_info,(MagickProgressMonitor) NULL, (void *) NULL); if (read_info->size == (char *) NULL) (void) CloneString(&read_info->size,DefaultTileGeometry); for (i=0; i < (ssize_t) number_files; i++) { if (image_info->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(),"name: %s", filelist[i]); (void) CopyMagickString(read_info->filename,filelist[i],MaxTextExtent); filelist[i]=DestroyString(filelist[i]); *read_info->magick='\0'; next_image=ReadImage(read_info,exception); CatchException(exception); if (next_image == (Image *) NULL) break; label=InterpretImageProperties(image_info,next_image,DefaultTileLabel); (void) SetImageProperty(next_image,"label",label); label=DestroyString(label); if (image_info->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "geometry: %.20gx%.20g",(double) next_image->columns,(double) next_image->rows); SetGeometry(next_image,&geometry); (void) ParseMetaGeometry(read_info->size,&geometry.x,&geometry.y, &geometry.width,&geometry.height); thumbnail_image=ThumbnailImage(next_image,geometry.width,geometry.height, exception); if (thumbnail_image != (Image *) NULL) { next_image=DestroyImage(next_image); next_image=thumbnail_image; } if (image_info->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), "thumbnail geometry: %.20gx%.20g",(double) next_image->columns,(double) next_image->rows); AppendImageToList(&images,next_image); status=SetImageProgress(images,LoadImagesTag,i,number_files); if (status == MagickFalse) break; } read_info=DestroyImageInfo(read_info); filelist=(char **) RelinquishMagickMemory(filelist); if (images == (Image *) NULL) ThrowReaderException(CorruptImageError, "ImageFileDoesNotContainAnyImageData"); /* Create the visual image directory. */ montage_info=CloneMontageInfo(image_info,(MontageInfo *) NULL); if (image_info->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(),"creating montage"); montage_image=MontageImageList(image_info,montage_info, GetFirstImageInList(images),exception); montage_info=DestroyMontageInfo(montage_info); images=DestroyImageList(images); return(montage_image); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % P a r s e G r a v i t y G e o m e t r y % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ParseGravityGeometry() returns a region as defined by the geometry string % with respect to the image dimensions and its gravity. % % The format of the ParseGravityGeometry method is: % % MagickStatusType ParseGravityGeometry(Image *image,const char *geometry, % RectangeInfo *region_info,ExceptionInfo *exception) % % A description of each parameter follows: % % o geometry: The geometry (e.g. 100x100+10+10). % % o region_info: the region as defined by the geometry string with % respect to the image dimensions and its gravity. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickStatusType ParseGravityGeometry(const Image *image, const char *geometry,RectangleInfo *region_info,ExceptionInfo *exception) { MagickStatusType flags; size_t height, width; SetGeometry(image,region_info); if (image->page.width != 0) region_info->width=image->page.width; if (image->page.height != 0) region_info->height=image->page.height; flags=ParseAbsoluteGeometry(geometry,region_info); if (flags == NoValue) { (void) ThrowMagickException(exception,GetMagickModule(),OptionError, "InvalidGeometry","`%s'",geometry); return(flags); } if ((flags & PercentValue) != 0) { GeometryInfo geometry_info; MagickStatusType status; PointInfo scale; /* Geometry is a percentage of the image size. */ if (image->gravity != UndefinedGravity) flags|=XValue | YValue; status=ParseGeometry(geometry,&geometry_info); scale.x=geometry_info.rho; if ((status & RhoValue) == 0) scale.x=100.0; scale.y=geometry_info.sigma; if ((status & SigmaValue) == 0) scale.y=scale.x; region_info->width=(size_t) floor((scale.x*image->columns/100.0)+ 0.5); region_info->height=(size_t) floor((scale.y*image->rows/100.0)+ 0.5); } /* Adjust offset according to gravity setting. */ width=region_info->width; height=region_info->height; if (width == 0) region_info->width=image->page.width | image->columns; if (height == 0) region_info->height=image->page.height | image->rows; GravityAdjustGeometry(image->columns,image->rows,image->gravity,region_info); region_info->width=width; region_info->height=height; return(flags); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % W r i t e H I S T O G R A M I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % WriteHISTOGRAMImage() writes an image to a file in Histogram format. % The image shows a histogram of the color (or gray) values in the image. The % image consists of three overlaid histograms: a red one for the red channel, % a green one for the green channel, and a blue one for the blue channel. The % image comment contains a list of unique pixel values and the number of times % each occurs in the image. % % This method is strongly based on a similar one written by % [email protected] which in turn is based on ppmhistmap of netpbm. % % The format of the WriteHISTOGRAMImage method is: % % MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info, % Image *image,ExceptionInfo *exception) % % A description of each parameter follows. % % o image_info: the image info. % % o image: The image. % % o exception: return any errors or warnings in this structure. % */ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info, Image *image,ExceptionInfo *exception) { #define HistogramDensity "256x200" char filename[MagickPathExtent]; const char *option; Image *histogram_image; ImageInfo *write_info; MagickBooleanType status; PixelInfo *histogram; double maximum, scale; RectangleInfo geometry; register const Quantum *p; register Quantum *q, *r; register ssize_t x; size_t length; ssize_t y; /* Allocate histogram image. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); SetGeometry(image,&geometry); if (image_info->density == (char *) NULL) (void) ParseAbsoluteGeometry(HistogramDensity,&geometry); else (void) ParseAbsoluteGeometry(image_info->density,&geometry); histogram_image=CloneImage(image,geometry.width,geometry.height,MagickTrue, exception); if (histogram_image == (Image *) NULL) ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); (void) SetImageStorageClass(histogram_image,DirectClass,exception); /* Allocate histogram count arrays. */ length=MagickMax((size_t) ScaleQuantumToChar(QuantumRange)+1UL, histogram_image->columns); histogram=(PixelInfo *) AcquireQuantumMemory(length,sizeof(*histogram)); if (histogram == (PixelInfo *) NULL) { histogram_image=DestroyImage(histogram_image); ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); } /* Initialize histogram count arrays. */ (void) ResetMagickMemory(histogram,0,length*sizeof(*histogram)); for (y=0; y < (ssize_t) image->rows; y++) { p=GetVirtualPixels(image,0,y,image->columns,1,exception); if (p == (const Quantum *) NULL) break; for (x=0; x < (ssize_t) image->columns; x++) { if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) histogram[ScaleQuantumToChar(GetPixelRed(image,p))].red++; if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) histogram[ScaleQuantumToChar(GetPixelGreen(image,p))].green++; if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) histogram[ScaleQuantumToChar(GetPixelBlue(image,p))].blue++; p+=GetPixelChannels(image); } } maximum=histogram[0].red; for (x=0; x < (ssize_t) histogram_image->columns; x++) { if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) && (maximum < histogram[x].red)) maximum=histogram[x].red; if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) && (maximum < histogram[x].green)) maximum=histogram[x].green; if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) && (maximum < histogram[x].blue)) maximum=histogram[x].blue; } scale=0.0; if (fabs(maximum) >= MagickEpsilon) scale=(double) histogram_image->rows/maximum; /* Initialize histogram image. */ (void) QueryColorCompliance("#000000",AllCompliance, &histogram_image->background_color,exception); (void) SetImageBackgroundColor(histogram_image,exception); for (x=0; x < (ssize_t) histogram_image->columns; x++) { q=GetAuthenticPixels(histogram_image,x,0,1,histogram_image->rows,exception); if (q == (Quantum *) NULL) break; if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) { y=(ssize_t) ceil(histogram_image->rows-scale*histogram[x].red-0.5); r=q+y*GetPixelChannels(histogram_image); for ( ; y < (ssize_t) histogram_image->rows; y++) { SetPixelRed(histogram_image,QuantumRange,r); r+=GetPixelChannels(histogram_image); } } if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) { y=(ssize_t) ceil(histogram_image->rows-scale*histogram[x].green-0.5); r=q+y*GetPixelChannels(histogram_image); for ( ; y < (ssize_t) histogram_image->rows; y++) { SetPixelGreen(histogram_image,QuantumRange,r); r+=GetPixelChannels(histogram_image); } } if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) { y=(ssize_t) ceil(histogram_image->rows-scale*histogram[x].blue-0.5); r=q+y*GetPixelChannels(histogram_image); for ( ; y < (ssize_t) histogram_image->rows; y++) { SetPixelBlue(histogram_image,QuantumRange,r); r+=GetPixelChannels(histogram_image); } } if (SyncAuthenticPixels(histogram_image,exception) == MagickFalse) break; status=SetImageProgress(image,SaveImageTag,y,histogram_image->rows); if (status == MagickFalse) break; } histogram=(PixelInfo *) RelinquishMagickMemory(histogram); option=GetImageOption(image_info,"histogram:unique-colors"); if ((option == (const char *) NULL) || (IsStringTrue(option) != MagickFalse)) { FILE *file; int unique_file; /* Add a unique colors as an image comment. */ file=(FILE *) NULL; unique_file=AcquireUniqueFileResource(filename); if (unique_file != -1) file=fdopen(unique_file,"wb"); if ((unique_file != -1) && (file != (FILE *) NULL)) { char *property; (void) GetNumberColors(image,file,exception); (void) fclose(file); property=FileToString(filename,~0UL,exception); if (property != (char *) NULL) { (void) SetImageProperty(histogram_image,"comment",property, exception); property=DestroyString(property); } } (void) RelinquishUniqueFileResource(filename); } /* Write Histogram image. */ (void) CopyMagickString(histogram_image->filename,image_info->filename, MagickPathExtent); write_info=CloneImageInfo(image_info); *write_info->magick='\0'; (void) SetImageInfo(write_info,1,exception); if ((*write_info->magick == '\0') || (LocaleCompare(write_info->magick,"HISTOGRAM") == 0)) (void) FormatLocaleString(histogram_image->filename,MagickPathExtent, "miff:%s",write_info->filename); histogram_image->blob=DetachBlob(histogram_image->blob); histogram_image->blob=CloneBlobInfo(image->blob); status=WriteImage(write_info,histogram_image,exception); image->blob=DetachBlob(image->blob); image->blob=CloneBlobInfo(histogram_image->blob); histogram_image=DestroyImage(histogram_image); write_info=DestroyImageInfo(write_info); return(status); }
static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image) { static const char *PostscriptProlog[]= { "%%%%BeginProlog", "%%", "%% Display a color image. The image is displayed in color on", "%% Postscript viewers or printers that support color, otherwise", "%% it is displayed as grayscale.", "%%", "/DirectClassImage", "{", " %%", " %% Display a DirectClass image.", " %%", " colorspace 0 eq", " {", " /DeviceRGB setcolorspace", " <<", " /ImageType 1", " /Width columns", " /Height rows", " /BitsPerComponent 8", " /Decode [0 1 0 1 0 1]", " /ImageMatrix [columns 0 0 rows neg 0 rows]", " compression 0 gt", " { /DataSource pixel_stream %s }", " { /DataSource pixel_stream %s } ifelse", " >> image", " }", " {", " /DeviceCMYK setcolorspace", " <<", " /ImageType 1", " /Width columns", " /Height rows", " /BitsPerComponent 8", " /Decode [1 0 1 0 1 0 1 0]", " /ImageMatrix [columns 0 0 rows neg 0 rows]", " compression 0 gt", " { /DataSource pixel_stream %s }", " { /DataSource pixel_stream %s } ifelse", " >> image", " } ifelse", "} bind def", "", "/PseudoClassImage", "{", " %%", " %% Display a PseudoClass image.", " %%", " %% Parameters:", " %% colors: number of colors in the colormap.", " %%", " currentfile buffer readline pop", " token pop /colors exch def pop", " colors 0 eq", " {", " %%", " %% Image is grayscale.", " %%", " currentfile buffer readline pop", " token pop /bits exch def pop", " /DeviceGray setcolorspace", " <<", " /ImageType 1", " /Width columns", " /Height rows", " /BitsPerComponent bits", " /Decode [0 1]", " /ImageMatrix [columns 0 0 rows neg 0 rows]", " compression 0 gt", " { /DataSource pixel_stream %s }", " {", " /DataSource pixel_stream %s", " <<", " /K "CCITTParam, " /Columns columns", " /Rows rows", " >> /CCITTFaxDecode filter", " } ifelse", " >> image", " }", " {", " %%", " %% Parameters:", " %% colormap: red, green, blue color packets.", " %%", " /colormap colors 3 mul string def", " currentfile colormap readhexstring pop pop", " currentfile buffer readline pop", " [ /Indexed /DeviceRGB colors 1 sub colormap ] setcolorspace", " <<", " /ImageType 1", " /Width columns", " /Height rows", " /BitsPerComponent 8", " /Decode [0 255]", " /ImageMatrix [columns 0 0 rows neg 0 rows]", " compression 0 gt", " { /DataSource pixel_stream %s }", " { /DataSource pixel_stream %s } ifelse", " >> image", " } ifelse", "} bind def", "", "/DisplayImage", "{", " %%", " %% Display a DirectClass or PseudoClass image.", " %%", " %% Parameters:", " %% x & y translation.", " %% x & y scale.", " %% label pointsize.", " %% image label.", " %% image columns & rows.", " %% class: 0-DirectClass or 1-PseudoClass.", " %% colorspace: 0-RGB or 1-CMYK.", " %% compression: 0-RLECompression or 1-NoCompression.", " %% hex color packets.", " %%", " gsave", " /buffer 512 string def", " /pixel_stream currentfile def", "", " currentfile buffer readline pop", " token pop /x exch def", " token pop /y exch def pop", " x y translate", " currentfile buffer readline pop", " token pop /x exch def", " token pop /y exch def pop", " currentfile buffer readline pop", " token pop /pointsize exch def pop", " /Helvetica findfont pointsize scalefont setfont", (char *) NULL }, *PostscriptEpilog[]= { " x y scale", " currentfile buffer readline pop", " token pop /columns exch def", " token pop /rows exch def pop", " currentfile buffer readline pop", " token pop /class exch def pop", " currentfile buffer readline pop", " token pop /colorspace exch def pop", " currentfile buffer readline pop", " token pop /compression exch def pop", " class 0 gt { PseudoClassImage } { DirectClassImage } ifelse", (char *) NULL }; char buffer[MaxTextExtent], date[MaxTextExtent], page_geometry[MaxTextExtent], **labels; CompressionType compression; const char **q, *value; double pointsize; GeometryInfo geometry_info; MagickOffsetType scene, start, stop; MagickBooleanType progress, status; MagickOffsetType offset; MagickSizeType number_pixels; MagickStatusType flags; PointInfo delta, resolution, scale; RectangleInfo geometry, media_info, page_info; register const IndexPacket *indexes; register const PixelPacket *p; register ssize_t x; register ssize_t i; SegmentInfo bounds; size_t length, page, text_size; ssize_t j, y; time_t timer; unsigned char *pixels; /* Open output image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); if (status == MagickFalse) return(status); compression=image->compression; if (image_info->compression != UndefinedCompression) compression=image_info->compression; switch (compression) { #if !defined(MAGICKCORE_JPEG_DELEGATE) case JPEGCompression: { compression=RLECompression; (void) ThrowMagickException(&image->exception,GetMagickModule(), MissingDelegateError,"DelegateLibrarySupportNotBuiltIn","`%s' (JPEG)", image->filename); break; } #endif default: break; } (void) ResetMagickMemory(&bounds,0,sizeof(bounds)); page=1; scene=0; do { /* Scale relative to dots-per-inch. */ delta.x=DefaultResolution; delta.y=DefaultResolution; resolution.x=image->x_resolution; resolution.y=image->y_resolution; if ((resolution.x == 0.0) || (resolution.y == 0.0)) { flags=ParseGeometry(PSDensityGeometry,&geometry_info); resolution.x=geometry_info.rho; resolution.y=geometry_info.sigma; if ((flags & SigmaValue) == 0) resolution.y=resolution.x; } if (image_info->density != (char *) NULL) { flags=ParseGeometry(image_info->density,&geometry_info); resolution.x=geometry_info.rho; resolution.y=geometry_info.sigma; if ((flags & SigmaValue) == 0) resolution.y=resolution.x; } if (image->units == PixelsPerCentimeterResolution) { resolution.x=(size_t) (100.0*2.54*resolution.x+0.5)/100.0; resolution.y=(size_t) (100.0*2.54*resolution.y+0.5)/100.0; } SetGeometry(image,&geometry); (void) FormatLocaleString(page_geometry,MaxTextExtent,"%.20gx%.20g", (double) image->columns,(double) image->rows); if (image_info->page != (char *) NULL) (void) CopyMagickString(page_geometry,image_info->page,MaxTextExtent); else if ((image->page.width != 0) && (image->page.height != 0)) (void) FormatLocaleString(page_geometry,MaxTextExtent, "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,(double) image->page.height,(double) image->page.x,(double) image->page.y); else if ((image->gravity != UndefinedGravity) && (LocaleCompare(image_info->magick,"PS") == 0)) (void) CopyMagickString(page_geometry,PSPageGeometry,MaxTextExtent); (void) ConcatenateMagickString(page_geometry,">",MaxTextExtent); (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y, &geometry.width,&geometry.height); scale.x=(double) (geometry.width*delta.x)/resolution.x; geometry.width=(size_t) floor(scale.x+0.5); scale.y=(double) (geometry.height*delta.y)/resolution.y; geometry.height=(size_t) floor(scale.y+0.5); (void) ParseAbsoluteGeometry(page_geometry,&media_info); (void) ParseGravityGeometry(image,page_geometry,&page_info, &image->exception); if (image->gravity != UndefinedGravity) { geometry.x=(-page_info.x); geometry.y=(ssize_t) (media_info.height+page_info.y-image->rows); } pointsize=12.0; if (image_info->pointsize != 0.0) pointsize=image_info->pointsize; text_size=0; value=GetImageProperty(image,"label"); if (value != (const char *) NULL) text_size=(size_t) (MultilineCensus(value)*pointsize+12); if (page == 1) { /* Output Postscript header. */ if (LocaleCompare(image_info->magick,"PS2") == 0) (void) CopyMagickString(buffer,"%!PS-Adobe-3.0\n",MaxTextExtent); else (void) CopyMagickString(buffer,"%!PS-Adobe-3.0 EPSF-3.0\n", MaxTextExtent); (void) WriteBlobString(image,buffer); (void) WriteBlobString(image,"%%Creator: (ImageMagick)\n"); (void) FormatLocaleString(buffer,MaxTextExtent,"%%%%Title: (%s)\n", image->filename); (void) WriteBlobString(image,buffer); timer=time((time_t *) NULL); (void) FormatMagickTime(timer,MaxTextExtent,date); (void) FormatLocaleString(buffer,MaxTextExtent, "%%%%CreationDate: (%s)\n",date); (void) WriteBlobString(image,buffer); bounds.x1=(double) geometry.x; bounds.y1=(double) geometry.y; bounds.x2=(double) geometry.x+geometry.width; bounds.y2=(double) geometry.y+geometry.height+text_size; if ((image_info->adjoin != MagickFalse) && (GetNextImageInList(image) != (Image *) NULL)) (void) CopyMagickString(buffer,"%%BoundingBox: (atend)\n", MaxTextExtent); else { (void) FormatLocaleString(buffer,MaxTextExtent, "%%%%BoundingBox: %.20g %.20g %.20g %.20g\n",ceil(bounds.x1-0.5), ceil(bounds.y1-0.5),floor(bounds.x2+0.5),floor(bounds.y2+0.5)); (void) WriteBlobString(image,buffer); (void) FormatLocaleString(buffer,MaxTextExtent, "%%%%HiResBoundingBox: %g %g %g %g\n",bounds.x1, bounds.y1,bounds.x2,bounds.y2); } (void) WriteBlobString(image,buffer); value=GetImageProperty(image,"label"); if (value != (const char *) NULL) (void) WriteBlobString(image, "%%DocumentNeededResources: font Helvetica\n"); (void) WriteBlobString(image,"%%LanguageLevel: 2\n"); if (LocaleCompare(image_info->magick,"PS2") != 0) (void) WriteBlobString(image,"%%Pages: 1\n"); else { (void) WriteBlobString(image,"%%Orientation: Portrait\n"); (void) WriteBlobString(image,"%%PageOrder: Ascend\n"); if (image_info->adjoin == MagickFalse) (void) CopyMagickString(buffer,"%%Pages: 1\n",MaxTextExtent); else (void) FormatLocaleString(buffer,MaxTextExtent, "%%%%Pages: %.20g\n",(double) GetImageListLength(image)); (void) WriteBlobString(image,buffer); } (void) WriteBlobString(image,"%%EndComments\n"); (void) WriteBlobString(image,"\n%%BeginDefaults\n"); (void) WriteBlobString(image,"%%EndDefaults\n\n"); /* Output Postscript commands. */ for (q=PostscriptProlog; *q; q++) { switch (compression) { case NoCompression: { (void) FormatLocaleString(buffer,MaxTextExtent,*q, "/ASCII85Decode filter"); break; } case JPEGCompression: { (void) FormatLocaleString(buffer,MaxTextExtent,*q, "/DCTDecode filter"); break; } case LZWCompression: { (void) FormatLocaleString(buffer,MaxTextExtent,*q, "/LZWDecode filter"); break; } case FaxCompression: case Group4Compression: { (void) FormatLocaleString(buffer,MaxTextExtent,*q," "); break; } default: { (void) FormatLocaleString(buffer,MaxTextExtent,*q, "/RunLengthDecode filter"); break; } } (void) WriteBlobString(image,buffer); (void) WriteBlobByte(image,'\n'); } value=GetImageProperty(image,"label"); if (value != (const char *) NULL) for (j=(ssize_t) MultilineCensus(value)-1; j >= 0; j--) { (void) WriteBlobString(image," /label 512 string def\n"); (void) WriteBlobString(image," currentfile label readline pop\n"); (void) FormatLocaleString(buffer,MaxTextExtent, " 0 y %g add moveto label show pop\n",j*pointsize+12); (void) WriteBlobString(image,buffer); } for (q=PostscriptEpilog; *q; q++) { (void) FormatLocaleString(buffer,MaxTextExtent,"%s\n",*q); (void) WriteBlobString(image,buffer); } if (LocaleCompare(image_info->magick,"PS2") == 0) (void) WriteBlobString(image," showpage\n"); (void) WriteBlobString(image,"} bind def\n"); (void) WriteBlobString(image,"%%EndProlog\n"); } (void) FormatLocaleString(buffer,MaxTextExtent,"%%%%Page: 1 %.20g\n", (double) page++); (void) WriteBlobString(image,buffer); (void) FormatLocaleString(buffer,MaxTextExtent, "%%%%PageBoundingBox: %.20g %.20g %.20g %.20g\n",(double) geometry.x, (double) geometry.y,geometry.x+(double) geometry.width,geometry.y+(double) (geometry.height+text_size)); (void) WriteBlobString(image,buffer); if ((double) geometry.x < bounds.x1) bounds.x1=(double) geometry.x; if ((double) geometry.y < bounds.y1) bounds.y1=(double) geometry.y; if ((double) (geometry.x+geometry.width-1) > bounds.x2) bounds.x2=(double) geometry.x+geometry.width-1; if ((double) (geometry.y+(geometry.height+text_size)-1) > bounds.y2) bounds.y2=(double) geometry.y+(geometry.height+text_size)-1; value=GetImageProperty(image,"label"); if (value != (const char *) NULL) (void) WriteBlobString(image,"%%PageResources: font Times-Roman\n"); if (LocaleCompare(image_info->magick,"PS2") != 0) (void) WriteBlobString(image,"userdict begin\n"); start=TellBlob(image); (void) FormatLocaleString(buffer,MaxTextExtent, "%%%%BeginData:%13ld %s Bytes\n",0L, compression == NoCompression ? "ASCII" : "Binary"); (void) WriteBlobString(image,buffer); stop=TellBlob(image); (void) WriteBlobString(image,"DisplayImage\n"); /* Output image data. */ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g %.20g\n%g %g\n%g\n", (double) geometry.x,(double) geometry.y,scale.x,scale.y,pointsize); (void) WriteBlobString(image,buffer); labels=(char **) NULL; value=GetImageProperty(image,"label"); if (value != (const char *) NULL) labels=StringToList(value); if (labels != (char **) NULL) { for (i=0; labels[i] != (char *) NULL; i++) { (void) FormatLocaleString(buffer,MaxTextExtent,"%s \n", labels[i]); (void) WriteBlobString(image,buffer); labels[i]=DestroyString(labels[i]); } labels=(char **) RelinquishMagickMemory(labels); } number_pixels=(MagickSizeType) image->columns*image->rows; if (number_pixels != (MagickSizeType) ((size_t) number_pixels)) ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); if ((compression == FaxCompression) || (compression == Group4Compression) || ((image_info->type != TrueColorType) && (IsGrayImage(image,&image->exception) != MagickFalse))) { (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g %.20g\n1\n%d\n", (double) image->columns,(double) image->rows,(int) (image->colorspace == CMYKColorspace)); (void) WriteBlobString(image,buffer); (void) FormatLocaleString(buffer,MaxTextExtent,"%d\n", (int) ((compression != FaxCompression) && (compression != Group4Compression))); (void) WriteBlobString(image,buffer); (void) WriteBlobString(image,"0\n"); (void) FormatLocaleString(buffer,MaxTextExtent,"%d\n", (compression == FaxCompression) || (compression == Group4Compression) ? 1 : 8); (void) WriteBlobString(image,buffer); switch (compression) { case FaxCompression: case Group4Compression: { if (LocaleCompare(CCITTParam,"0") == 0) { (void) HuffmanEncodeImage(image_info,image,image); break; } (void) Huffman2DEncodeImage(image_info,image,image); break; } case JPEGCompression: { status=InjectImageBlob(image_info,image,image,"jpeg", &image->exception); if (status == MagickFalse) ThrowWriterException(CoderError,image->exception.reason); break; } case RLECompression: default: { register unsigned char *q; /* Allocate pixel array. */ length=(size_t) number_pixels; pixels=(unsigned char *) AcquireQuantumMemory(length, sizeof(*pixels)); if (pixels == (unsigned char *) NULL) ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); /* Dump Runlength encoded pixels. */ q=pixels; for (y=0; y < (ssize_t) image->rows; y++) { p=GetVirtualPixels(image,0,y,image->columns,1, &image->exception); if (p == (const PixelPacket *) NULL) break; for (x=0; x < (ssize_t) image->columns; x++) { *q++=ScaleQuantumToChar(PixelIntensityToQuantum(p)); p++; } progress=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, image->rows); if (progress == MagickFalse) break; } length=(size_t) (q-pixels); if (compression == LZWCompression) status=LZWEncodeImage(image,length,pixels); else status=PackbitsEncodeImage(image,length,pixels); pixels=(unsigned char *) RelinquishMagickMemory(pixels); if (status == MagickFalse) { (void) CloseBlob(image); return(MagickFalse); } break; } case NoCompression: { /* Dump uncompressed PseudoColor packets. */ Ascii85Initialize(image); for (y=0; y < (ssize_t) image->rows; y++) { p=GetVirtualPixels(image,0,y,image->columns,1, &image->exception); if (p == (const PixelPacket *) NULL) break; for (x=0; x < (ssize_t) image->columns; x++) { Ascii85Encode(image,ScaleQuantumToChar( PixelIntensityToQuantum(p))); p++; } progress=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,image->rows); if (progress == MagickFalse) break; } Ascii85Flush(image); break; } } } else if ((image->storage_class == DirectClass) || (image->colors > 256) || (compression == JPEGCompression) || (image->matte != MagickFalse)) { (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g %.20g\n0\n%d\n", (double) image->columns,(double) image->rows,(int) (image->colorspace == CMYKColorspace)); (void) WriteBlobString(image,buffer); (void) FormatLocaleString(buffer,MaxTextExtent,"%d\n", (int) (compression == NoCompression)); (void) WriteBlobString(image,buffer); switch (compression) { case JPEGCompression: { status=InjectImageBlob(image_info,image,image,"jpeg", &image->exception); if (status == MagickFalse) ThrowWriterException(CoderError,image->exception.reason); break; } case RLECompression: default: { register unsigned char *q; /* Allocate pixel array. */ length=(size_t) number_pixels; pixels=(unsigned char *) AcquireQuantumMemory(length, 4*sizeof(*pixels)); if (pixels == (unsigned char *) NULL) ThrowWriterException(ResourceLimitError, "MemoryAllocationFailed"); /* Dump Packbit encoded pixels. */ q=pixels; for (y=0; y < (ssize_t) image->rows; y++) { p=GetVirtualPixels(image,0,y,image->columns,1, &image->exception); if (p == (const PixelPacket *) NULL) break; indexes=GetVirtualIndexQueue(image); for (x=0; x < (ssize_t) image->columns; x++) { if ((image->matte != MagickFalse) && (GetPixelOpacity(p) == (Quantum) TransparentOpacity)) { *q++=ScaleQuantumToChar((Quantum) QuantumRange); *q++=ScaleQuantumToChar((Quantum) QuantumRange); *q++=ScaleQuantumToChar((Quantum) QuantumRange); } else if (image->colorspace != CMYKColorspace) { *q++=ScaleQuantumToChar(GetPixelRed(p)); *q++=ScaleQuantumToChar(GetPixelGreen(p)); *q++=ScaleQuantumToChar(GetPixelBlue(p)); } else { *q++=ScaleQuantumToChar(GetPixelRed(p)); *q++=ScaleQuantumToChar(GetPixelGreen(p)); *q++=ScaleQuantumToChar(GetPixelBlue(p)); *q++=ScaleQuantumToChar(GetPixelIndex( indexes+x)); } p++; } progress=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,image->rows); if (progress == MagickFalse) break; } length=(size_t) (q-pixels); if (compression == LZWCompression) status=LZWEncodeImage(image,length,pixels); else status=PackbitsEncodeImage(image,length,pixels); if (status == MagickFalse) { (void) CloseBlob(image); return(MagickFalse); } pixels=(unsigned char *) RelinquishMagickMemory(pixels); break; } case NoCompression: { /* Dump uncompressed DirectColor packets. */ Ascii85Initialize(image); for (y=0; y < (ssize_t) image->rows; y++) { p=GetVirtualPixels(image,0,y,image->columns,1, &image->exception); if (p == (const PixelPacket *) NULL) break; indexes=GetVirtualIndexQueue(image); for (x=0; x < (ssize_t) image->columns; x++) { if ((image->matte != MagickFalse) && (GetPixelOpacity(p) == (Quantum) TransparentOpacity)) { Ascii85Encode(image,ScaleQuantumToChar((Quantum) QuantumRange)); Ascii85Encode(image,ScaleQuantumToChar((Quantum) QuantumRange)); Ascii85Encode(image,ScaleQuantumToChar((Quantum) QuantumRange)); } else if (image->colorspace != CMYKColorspace) { Ascii85Encode(image,ScaleQuantumToChar( GetPixelRed(p))); Ascii85Encode(image,ScaleQuantumToChar( GetPixelGreen(p))); Ascii85Encode(image,ScaleQuantumToChar( GetPixelBlue(p))); } else { Ascii85Encode(image,ScaleQuantumToChar( GetPixelRed(p))); Ascii85Encode(image,ScaleQuantumToChar( GetPixelGreen(p))); Ascii85Encode(image,ScaleQuantumToChar( GetPixelBlue(p))); Ascii85Encode(image,ScaleQuantumToChar( GetPixelIndex(indexes+x))); } p++; } progress=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,image->rows); if (progress == MagickFalse) break; } Ascii85Flush(image); break; } } } else { /* Dump number of colors and colormap. */ (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g %.20g\n1\n%d\n", (double) image->columns,(double) image->rows,(int) (image->colorspace == CMYKColorspace)); (void) WriteBlobString(image,buffer); (void) FormatLocaleString(buffer,MaxTextExtent,"%d\n", (int) (compression == NoCompression)); (void) WriteBlobString(image,buffer); (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g\n",(double) image->colors); (void) WriteBlobString(image,buffer); for (i=0; i < (ssize_t) image->colors; i++) { (void) FormatLocaleString(buffer,MaxTextExtent,"%02X%02X%02X\n", ScaleQuantumToChar(image->colormap[i].red), ScaleQuantumToChar(image->colormap[i].green), ScaleQuantumToChar(image->colormap[i].blue)); (void) WriteBlobString(image,buffer); } switch (compression) { case RLECompression: default: { register unsigned char *q; /* Allocate pixel array. */ length=(size_t) number_pixels; pixels=(unsigned char *) AcquireQuantumMemory(length, sizeof(*pixels)); if (pixels == (unsigned char *) NULL) ThrowWriterException(ResourceLimitError, "MemoryAllocationFailed"); /* Dump Runlength encoded pixels. */ q=pixels; for (y=0; y < (ssize_t) image->rows; y++) { p=GetVirtualPixels(image,0,y,image->columns,1, &image->exception); if (p == (const PixelPacket *) NULL) break; indexes=GetVirtualIndexQueue(image); for (x=0; x < (ssize_t) image->columns; x++) *q++=(unsigned char) GetPixelIndex(indexes+x); progress=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,image->rows); if (progress == MagickFalse) break; } length=(size_t) (q-pixels); if (compression == LZWCompression) status=LZWEncodeImage(image,length,pixels); else status=PackbitsEncodeImage(image,length,pixels); pixels=(unsigned char *) RelinquishMagickMemory(pixels); if (status == MagickFalse) { (void) CloseBlob(image); return(MagickFalse); } break; } case NoCompression: { /* Dump uncompressed PseudoColor packets. */ Ascii85Initialize(image); for (y=0; y < (ssize_t) image->rows; y++) { p=GetVirtualPixels(image,0,y,image->columns,1, &image->exception); if (p == (const PixelPacket *) NULL) break; indexes=GetVirtualIndexQueue(image); for (x=0; x < (ssize_t) image->columns; x++) Ascii85Encode(image,(unsigned char) GetPixelIndex( indexes+x)); progress=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,image->rows); if (progress == MagickFalse) break; } Ascii85Flush(image); break; } } } (void) WriteBlobByte(image,'\n'); length=(size_t) (TellBlob(image)-stop); stop=TellBlob(image); offset=SeekBlob(image,start,SEEK_SET); if (offset < 0) ThrowWriterException(CorruptImageError,"ImproperImageHeader"); (void) FormatLocaleString(buffer,MaxTextExtent, "%%%%BeginData:%13ld %s Bytes\n",(long) length, compression == NoCompression ? "ASCII" : "Binary"); (void) WriteBlobString(image,buffer); offset=SeekBlob(image,stop,SEEK_SET); (void) WriteBlobString(image,"%%EndData\n"); if (LocaleCompare(image_info->magick,"PS2") != 0) (void) WriteBlobString(image,"end\n"); (void) WriteBlobString(image,"%%PageTrailer\n"); if (GetNextImageInList(image) == (Image *) NULL) break; image=SyncNextImageInList(image); status=SetImageProgress(image,SaveImagesTag,scene++, GetImageListLength(image)); if (status == MagickFalse) break; } while (image_info->adjoin != MagickFalse); (void) WriteBlobString(image,"%%Trailer\n"); if (page > 1) { (void) FormatLocaleString(buffer,MaxTextExtent, "%%%%BoundingBox: %.20g %.20g %.20g %.20g\n",ceil(bounds.x1-0.5), ceil(bounds.y1-0.5),floor(bounds.x2+0.5),floor(bounds.y2+0.5)); (void) WriteBlobString(image,buffer); (void) FormatLocaleString(buffer,MaxTextExtent, "%%%%HiResBoundingBox: %g %g %g %g\n",bounds.x1,bounds.y1, bounds.x2,bounds.y2); (void) WriteBlobString(image,buffer); } (void) WriteBlobString(image,"%%EOF\n"); (void) CloseBlob(image); return(MagickTrue); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % W r i t e P I C O N I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % WritePICONImage() writes an image to a file in the Personal Icon format. % % The format of the WritePICONImage method is: % % MagickBooleanType WritePICONImage(const ImageInfo *image_info, % Image *image) % % A description of each parameter follows. % % o image_info: the image info. % % o image: The image. % */ static MagickBooleanType WritePICONImage(const ImageInfo *image_info, Image *image) { #define ColormapExtent 155 #define GraymapExtent 95 #define PiconGeometry "48x48>" static unsigned char Colormap[]= { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x06, 0x00, 0x05, 0x00, 0xf4, 0x05, 0x00, 0x00, 0x00, 0x00, 0x2f, 0x4f, 0x4f, 0x70, 0x80, 0x90, 0x7e, 0x7e, 0x7e, 0xdc, 0xdc, 0xdc, 0xff, 0xff, 0xff, 0x00, 0x00, 0x80, 0x00, 0x00, 0xff, 0x1e, 0x90, 0xff, 0x87, 0xce, 0xeb, 0xe6, 0xe6, 0xfa, 0x00, 0xff, 0xff, 0x80, 0x00, 0x80, 0xb2, 0x22, 0x22, 0x2e, 0x8b, 0x57, 0x32, 0xcd, 0x32, 0x00, 0xff, 0x00, 0x98, 0xfb, 0x98, 0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x63, 0x47, 0xff, 0xa5, 0x00, 0xff, 0xd7, 0x00, 0xff, 0xff, 0x00, 0xee, 0x82, 0xee, 0xa0, 0x52, 0x2d, 0xcd, 0x85, 0x3f, 0xd2, 0xb4, 0x8c, 0xf5, 0xde, 0xb3, 0xff, 0xfa, 0xcd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xf9, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x05, 0x18, 0x20, 0x10, 0x08, 0x03, 0x51, 0x18, 0x07, 0x92, 0x28, 0x0b, 0xd3, 0x38, 0x0f, 0x14, 0x49, 0x13, 0x55, 0x59, 0x17, 0x96, 0x69, 0x1b, 0xd7, 0x85, 0x00, 0x3b, }, Graymap[]= { 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x04, 0x00, 0x04, 0x00, 0xf3, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x12, 0x12, 0x12, 0x21, 0x21, 0x21, 0x33, 0x33, 0x33, 0x45, 0x45, 0x45, 0x54, 0x54, 0x54, 0x66, 0x66, 0x66, 0x78, 0x78, 0x78, 0x87, 0x87, 0x87, 0x99, 0x99, 0x99, 0xab, 0xab, 0xab, 0xba, 0xba, 0xba, 0xcc, 0xcc, 0xcc, 0xde, 0xde, 0xde, 0xed, 0xed, 0xed, 0xff, 0xff, 0xff, 0x21, 0xf9, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04, 0x0c, 0x10, 0x04, 0x31, 0x48, 0x31, 0x07, 0x25, 0xb5, 0x58, 0x73, 0x4f, 0x04, 0x00, 0x3b, }; #define MaxCixels 92 static const char Cixel[MaxCixels+1] = " .XoO+@#$%&*=-;:>,<1234567890qwertyuipasdfghjk" "lzxcvbnmMNBVCZASDFGHJKLPIUYTREWQ!~^/()_`'][{}|"; char buffer[MaxTextExtent], basename[MaxTextExtent], name[MaxTextExtent], symbol[MaxTextExtent]; ExceptionInfo *exception; Image *affinity_image, *picon; ImageInfo *blob_info; MagickBooleanType status, transparent; MagickPixelPacket pixel; QuantizeInfo *quantize_info; RectangleInfo geometry; register const IndexPacket *indexes; register const PixelPacket *p; register ssize_t i, x; register PixelPacket *q; size_t characters_per_pixel, colors; ssize_t j, k, y; /* Open output image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); if (status == MagickFalse) return(status); (void) TransformImageColorspace(image,sRGBColorspace); SetGeometry(image,&geometry); (void) ParseMetaGeometry(PiconGeometry,&geometry.x,&geometry.y, &geometry.width,&geometry.height); picon=ResizeImage(image,geometry.width,geometry.height,TriangleFilter,1.0, &image->exception); blob_info=CloneImageInfo(image_info); (void) AcquireUniqueFilename(blob_info->filename); if ((image_info->type != TrueColorType) && (SetImageGray(image,&image->exception) != MagickFalse)) affinity_image=BlobToImage(blob_info,Graymap,GraymapExtent, &image->exception); else affinity_image=BlobToImage(blob_info,Colormap,ColormapExtent, &image->exception); (void) RelinquishUniqueFileResource(blob_info->filename); blob_info=DestroyImageInfo(blob_info); if ((picon == (Image *) NULL) || (affinity_image == (Image *) NULL)) return(MagickFalse); quantize_info=AcquireQuantizeInfo(image_info); status=RemapImage(quantize_info,picon,affinity_image); quantize_info=DestroyQuantizeInfo(quantize_info); affinity_image=DestroyImage(affinity_image); transparent=MagickFalse; exception=(&image->exception); if (picon->storage_class == PseudoClass) { (void) CompressImageColormap(picon); if (picon->matte != MagickFalse) transparent=MagickTrue; } else { /* Convert DirectClass to PseudoClass picon. */ if (picon->matte != MagickFalse) { /* Map all the transparent pixels. */ for (y=0; y < (ssize_t) picon->rows; y++) { q=GetAuthenticPixels(picon,0,y,picon->columns,1,exception); if (q == (PixelPacket *) NULL) break; for (x=0; x < (ssize_t) picon->columns; x++) { if (q->opacity == (Quantum) TransparentOpacity) transparent=MagickTrue; else SetPixelOpacity(q,OpaqueOpacity); q++; } if (SyncAuthenticPixels(picon,exception) == MagickFalse) break; } } (void) SetImageType(picon,PaletteType); } colors=picon->colors; if (transparent != MagickFalse) { register IndexPacket *indexes; colors++; picon->colormap=(PixelPacket *) ResizeQuantumMemory((void **) picon->colormap,(size_t) colors,sizeof(*picon->colormap)); if (picon->colormap == (PixelPacket *) NULL) ThrowWriterException(ResourceLimitError,"MemoryAllocationError"); for (y=0; y < (ssize_t) picon->rows; y++) { q=GetAuthenticPixels(picon,0,y,picon->columns,1,exception); if (q == (PixelPacket *) NULL) break; indexes=GetAuthenticIndexQueue(picon); for (x=0; x < (ssize_t) picon->columns; x++) { if (q->opacity == (Quantum) TransparentOpacity) SetPixelIndex(indexes+x,picon->colors); q++; } if (SyncAuthenticPixels(picon,exception) == MagickFalse) break; } } /* Compute the character per pixel. */ characters_per_pixel=1; for (k=MaxCixels; (ssize_t) colors > k; k*=MaxCixels) characters_per_pixel++; /* XPM header. */ (void) WriteBlobString(image,"/* XPM */\n"); GetPathComponent(picon->filename,BasePath,basename); (void) FormatLocaleString(buffer,MaxTextExtent, "static char *%s[] = {\n",basename); (void) WriteBlobString(image,buffer); (void) WriteBlobString(image,"/* columns rows colors chars-per-pixel */\n"); (void) FormatLocaleString(buffer,MaxTextExtent, "\"%.20g %.20g %.20g %.20g\",\n",(double) picon->columns,(double) picon->rows,(double) colors,(double) characters_per_pixel); (void) WriteBlobString(image,buffer); GetMagickPixelPacket(image,&pixel); for (i=0; i < (ssize_t) colors; i++) { /* Define XPM color. */ SetMagickPixelPacket(image,picon->colormap+i,(IndexPacket *) NULL,&pixel); pixel.colorspace=sRGBColorspace; pixel.depth=8; pixel.opacity=(MagickRealType) OpaqueOpacity; (void) QueryMagickColorname(image,&pixel,XPMCompliance,name, &image->exception); if (transparent != MagickFalse) { if (i == (ssize_t) (colors-1)) (void) CopyMagickString(name,"grey75",MaxTextExtent); } /* Write XPM color. */ k=i % MaxCixels; symbol[0]=Cixel[k]; for (j=1; j < (ssize_t) characters_per_pixel; j++) { k=((i-k)/MaxCixels) % MaxCixels; symbol[j]=Cixel[k]; } symbol[j]='\0'; (void) FormatLocaleString(buffer,MaxTextExtent,"\"%s c %s\",\n", symbol,name); (void) WriteBlobString(image,buffer); } /* Define XPM pixels. */ (void) WriteBlobString(image,"/* pixels */\n"); for (y=0; y < (ssize_t) picon->rows; y++) { p=GetVirtualPixels(picon,0,y,picon->columns,1,&picon->exception); if (p == (const PixelPacket *) NULL) break; indexes=GetVirtualIndexQueue(picon); (void) WriteBlobString(image,"\""); for (x=0; x < (ssize_t) picon->columns; x++) { k=((ssize_t) GetPixelIndex(indexes+x) % MaxCixels); symbol[0]=Cixel[k]; for (j=1; j < (ssize_t) characters_per_pixel; j++) { k=(((int) GetPixelIndex(indexes+x)-k)/MaxCixels) % MaxCixels; symbol[j]=Cixel[k]; } symbol[j]='\0'; (void) CopyMagickString(buffer,symbol,MaxTextExtent); (void) WriteBlobString(image,buffer); } (void) FormatLocaleString(buffer,MaxTextExtent,"\"%s\n", y == (ssize_t) (picon->rows-1) ? "" : ","); (void) WriteBlobString(image,buffer); status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, picon->rows); if (status == MagickFalse) break; } picon=DestroyImage(picon); (void) WriteBlobString(image,"};\n"); (void) CloseBlob(image); return(MagickTrue); }
MagickExport Image *MontageImageList(const ImageInfo *image_info, const MontageInfo *montage_info,const Image *images,ExceptionInfo *exception) { #define MontageImageTag "Montage/Image" #define TileImageTag "Tile/Image" char tile_geometry[MagickPathExtent], *title; const char *value; DrawInfo *draw_info; FrameInfo frame_info; Image *image, **image_list, **master_list, *montage, *texture, *tile_image, *thumbnail; ImageInfo *clone_info; MagickBooleanType concatenate, proceed, status; MagickOffsetType tiles; MagickProgressMonitor progress_monitor; MagickStatusType flags; register ssize_t i; RectangleInfo bounds, geometry, extract_info; size_t border_width, extent, height, images_per_page, max_height, number_images, number_lines, sans, tiles_per_column, tiles_per_page, tiles_per_row, title_offset, total_tiles, width; ssize_t bevel_width, tile, x, x_offset, y, y_offset; TypeMetric metrics; /* Create image tiles. */ assert(images != (Image *) NULL); assert(images->signature == MagickCoreSignature); if (images->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",images->filename); assert(montage_info != (MontageInfo *) NULL); assert(montage_info->signature == MagickCoreSignature); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickCoreSignature); number_images=GetImageListLength(images); master_list=ImageListToArray(images,exception); image_list=master_list; image=image_list[0]; if (master_list == (Image **) NULL) ThrowImageException(ResourceLimitError,"MemoryAllocationFailed"); thumbnail=NewImageList(); for (i=0; i < (ssize_t) number_images; i++) { image=CloneImage(image_list[i],0,0,MagickTrue,exception); if (image == (Image *) NULL) break; (void) ParseAbsoluteGeometry("0x0+0+0",&image->page); progress_monitor=SetImageProgressMonitor(image,(MagickProgressMonitor) NULL, image->client_data); flags=ParseRegionGeometry(image,montage_info->geometry,&geometry,exception); thumbnail=ThumbnailImage(image,geometry.width,geometry.height,exception); if (thumbnail == (Image *) NULL) break; image_list[i]=thumbnail; (void) SetImageProgressMonitor(image,progress_monitor,image->client_data); proceed=SetImageProgress(image,TileImageTag,(MagickOffsetType) i, number_images); if (proceed == MagickFalse) break; image=DestroyImage(image); } if (i < (ssize_t) number_images) { if (thumbnail == (Image *) NULL) i--; for (tile=0; (ssize_t) tile <= i; tile++) if (image_list[tile] != (Image *) NULL) image_list[tile]=DestroyImage(image_list[tile]); master_list=(Image **) RelinquishMagickMemory(master_list); return((Image *) NULL); } /* Sort image list by increasing tile number. */ for (i=0; i < (ssize_t) number_images; i++) if (image_list[i]->scene == 0) break; if (i == (ssize_t) number_images) qsort((void *) image_list,(size_t) number_images,sizeof(*image_list), SceneCompare); /* Determine tiles per row and column. */ tiles_per_column=(size_t) sqrt((double) number_images); tiles_per_row=(size_t) ceil((double) number_images/tiles_per_column); x_offset=0; y_offset=0; if (montage_info->tile != (char *) NULL) GetMontageGeometry(montage_info->tile,number_images,&x_offset,&y_offset, &tiles_per_column,&tiles_per_row); /* Determine tile sizes. */ concatenate=MagickFalse; SetGeometry(image_list[0],&extract_info); extract_info.x=(ssize_t) montage_info->border_width; extract_info.y=(ssize_t) montage_info->border_width; if (montage_info->geometry != (char *) NULL) { /* Initialize tile geometry. */ flags=GetGeometry(montage_info->geometry,&extract_info.x,&extract_info.y, &extract_info.width,&extract_info.height); concatenate=((flags & RhoValue) == 0) && ((flags & SigmaValue) == 0) ? MagickTrue : MagickFalse; } border_width=montage_info->border_width; bevel_width=0; (void) ResetMagickMemory(&frame_info,0,sizeof(frame_info)); if (montage_info->frame != (char *) NULL) { char absolute_geometry[MagickPathExtent]; frame_info.width=extract_info.width; frame_info.height=extract_info.height; (void) FormatLocaleString(absolute_geometry,MagickPathExtent,"%s!", montage_info->frame); flags=ParseMetaGeometry(absolute_geometry,&frame_info.outer_bevel, &frame_info.inner_bevel,&frame_info.width,&frame_info.height); if ((flags & HeightValue) == 0) frame_info.height=frame_info.width; if ((flags & XiValue) == 0) frame_info.outer_bevel=(ssize_t) frame_info.width/2-1; if ((flags & PsiValue) == 0) frame_info.inner_bevel=frame_info.outer_bevel; frame_info.x=(ssize_t) frame_info.width; frame_info.y=(ssize_t) frame_info.height; bevel_width=(ssize_t) MagickMax(frame_info.inner_bevel, frame_info.outer_bevel); border_width=(size_t) MagickMax((ssize_t) frame_info.width, (ssize_t) frame_info.height); } for (i=0; i < (ssize_t) number_images; i++) { if (image_list[i]->columns > extract_info.width) extract_info.width=image_list[i]->columns; if (image_list[i]->rows > extract_info.height) extract_info.height=image_list[i]->rows; } /* Initialize draw attributes. */ clone_info=CloneImageInfo(image_info); clone_info->background_color=montage_info->background_color; clone_info->border_color=montage_info->border_color; draw_info=CloneDrawInfo(clone_info,(DrawInfo *) NULL); if (montage_info->font != (char *) NULL) (void) CloneString(&draw_info->font,montage_info->font); if (montage_info->pointsize != 0.0) draw_info->pointsize=montage_info->pointsize; draw_info->gravity=CenterGravity; draw_info->stroke=montage_info->stroke; draw_info->fill=montage_info->fill; draw_info->text=AcquireString(""); (void) GetTypeMetrics(image_list[0],draw_info,&metrics,exception); texture=NewImageList(); if (montage_info->texture != (char *) NULL) { (void) CopyMagickString(clone_info->filename,montage_info->texture, MagickPathExtent); texture=ReadImage(clone_info,exception); } /* Determine the number of lines in an next label. */ title=InterpretImageProperties(clone_info,image_list[0],montage_info->title, exception); title_offset=0; if (montage_info->title != (char *) NULL) title_offset=(size_t) (2*(metrics.ascent-metrics.descent)* MultilineCensus(title)+2*extract_info.y); number_lines=0; for (i=0; i < (ssize_t) number_images; i++) { value=GetImageProperty(image_list[i],"label",exception); if (value == (const char *) NULL) continue; if (MultilineCensus(value) > number_lines) number_lines=MultilineCensus(value); } /* Allocate next structure. */ tile_image=AcquireImage((ImageInfo *) NULL,exception); montage=AcquireImage(clone_info,exception); montage->background_color=montage_info->background_color; montage->scene=0; images_per_page=(number_images-1)/(tiles_per_row*tiles_per_column)+1; tiles=0; total_tiles=(size_t) number_images; for (i=0; i < (ssize_t) images_per_page; i++) { /* Determine bounding box. */ tiles_per_page=tiles_per_row*tiles_per_column; x_offset=0; y_offset=0; if (montage_info->tile != (char *) NULL) GetMontageGeometry(montage_info->tile,number_images,&x_offset,&y_offset, &sans,&sans); tiles_per_page=tiles_per_row*tiles_per_column; y_offset+=(ssize_t) title_offset; max_height=0; bounds.width=0; bounds.height=0; width=0; for (tile=0; tile < (ssize_t) tiles_per_page; tile++) { if (tile < (ssize_t) number_images) { width=concatenate != MagickFalse ? image_list[tile]->columns : extract_info.width; if (image_list[tile]->rows > max_height) max_height=image_list[tile]->rows; } x_offset+=(ssize_t) (width+2*(extract_info.x+border_width)); if (x_offset > (ssize_t) bounds.width) bounds.width=(size_t) x_offset; if (((tile+1) == (ssize_t) tiles_per_page) || (((tile+1) % tiles_per_row) == 0)) { x_offset=0; if (montage_info->tile != (char *) NULL) GetMontageGeometry(montage_info->tile,number_images,&x_offset,&y, &sans,&sans); height=concatenate != MagickFalse ? max_height : extract_info.height; y_offset+=(ssize_t) (height+(extract_info.y+(ssize_t) border_width)*2+ (metrics.ascent-metrics.descent+4)*number_lines+ (montage_info->shadow != MagickFalse ? 4 : 0)); if (y_offset > (ssize_t) bounds.height) bounds.height=(size_t) y_offset; max_height=0; } } if (montage_info->shadow != MagickFalse) bounds.width+=4; /* Initialize montage image. */ (void) CopyMagickString(montage->filename,montage_info->filename, MagickPathExtent); montage->columns=(size_t) MagickMax((ssize_t) bounds.width,1); montage->rows=(size_t) MagickMax((ssize_t) bounds.height,1); (void) SetImageBackgroundColor(montage,exception); /* Set montage geometry. */ montage->montage=AcquireString((char *) NULL); tile=0; extent=1; while (tile < MagickMin((ssize_t) tiles_per_page,(ssize_t) number_images)) { extent+=strlen(image_list[tile]->filename)+1; tile++; } montage->directory=(char *) AcquireQuantumMemory(extent, sizeof(*montage->directory)); if ((montage->montage == (char *) NULL) || (montage->directory == (char *) NULL)) { if (montage->montage != (char *) NULL) montage->montage=(char *) RelinquishMagickMemory(montage->montage); if (montage->directory != (char *) NULL) montage->directory=(char *) RelinquishMagickMemory( montage->directory); ThrowImageException(ResourceLimitError,"MemoryAllocationFailed"); } x_offset=0; y_offset=0; if (montage_info->tile != (char *) NULL) GetMontageGeometry(montage_info->tile,number_images,&x_offset,&y_offset, &sans,&sans); y_offset+=(ssize_t) title_offset; (void) FormatLocaleString(montage->montage,MagickPathExtent, "%.20gx%.20g%+.20g%+.20g",(double) (extract_info.width+ (extract_info.x+border_width)*2),(double) (extract_info.height+ (extract_info.y+border_width)*2+(double) ((metrics.ascent- metrics.descent+4)*number_lines+(montage_info->shadow != MagickFalse ? 4 : 0))),(double) x_offset,(double) y_offset); *montage->directory='\0'; tile=0; while (tile < MagickMin((ssize_t) tiles_per_page,(ssize_t) number_images)) { (void) ConcatenateMagickString(montage->directory, image_list[tile]->filename,extent); (void) ConcatenateMagickString(montage->directory,"\n",extent); tile++; } progress_monitor=SetImageProgressMonitor(montage,(MagickProgressMonitor) NULL,montage->client_data); if (texture != (Image *) NULL) (void) TextureImage(montage,texture,exception); if (montage_info->title != (char *) NULL) { DrawInfo *draw_clone_info; TypeMetric tile_metrics; /* Annotate composite image with title. */ draw_clone_info=CloneDrawInfo(image_info,draw_info); draw_clone_info->gravity=CenterGravity; draw_clone_info->pointsize*=2.0; (void) GetTypeMetrics(image_list[0],draw_clone_info,&tile_metrics, exception); (void) FormatLocaleString(tile_geometry,MagickPathExtent, "%.20gx%.20g%+.20g%+.20g",(double) montage->columns,(double) (tile_metrics.ascent-tile_metrics.descent),0.0, (double) extract_info.y+4); (void) CloneString(&draw_clone_info->geometry,tile_geometry); (void) CloneString(&draw_clone_info->text,title); (void) AnnotateImage(montage,draw_clone_info,exception); draw_clone_info=DestroyDrawInfo(draw_clone_info); } (void) SetImageProgressMonitor(montage,progress_monitor, montage->client_data); /* Copy tile to the composite. */ x_offset=0; y_offset=0; if (montage_info->tile != (char *) NULL) GetMontageGeometry(montage_info->tile,number_images,&x_offset,&y_offset, &sans,&sans); x_offset+=extract_info.x; y_offset+=(ssize_t) title_offset+extract_info.y; max_height=0; status=MagickTrue; for (tile=0; tile < MagickMin((ssize_t) tiles_per_page,(ssize_t) number_images); tile++) { /* Copy this tile to the composite. */ image=CloneImage(image_list[tile],0,0,MagickTrue,exception); if (image == (Image *) NULL) ThrowImageException(ResourceLimitError,"MemoryAllocationFailed"); progress_monitor=SetImageProgressMonitor(image, (MagickProgressMonitor) NULL,image->client_data); width=concatenate != MagickFalse ? image->columns : extract_info.width; if (image->rows > max_height) max_height=image->rows; height=concatenate != MagickFalse ? max_height : extract_info.height; if (border_width != 0) { Image *border_image; RectangleInfo border_info; /* Put a border around the image. */ border_info.width=border_width; border_info.height=border_width; if (montage_info->frame != (char *) NULL) { border_info.width=(width-image->columns+1)/2; border_info.height=(height-image->rows+1)/2; } border_image=BorderImage(image,&border_info,image->compose,exception); if (border_image != (Image *) NULL) { image=DestroyImage(image); image=border_image; } if ((montage_info->frame != (char *) NULL) && (image->compose == DstOutCompositeOp)) { (void) SetPixelChannelMask(image,AlphaChannel); (void) NegateImage(image,MagickFalse,exception); (void) SetPixelChannelMask(image,DefaultChannels); } } /* Gravitate as specified by the tile gravity. */ tile_image->columns=width; tile_image->rows=height; tile_image->gravity=montage_info->gravity; if (image->gravity != UndefinedGravity) tile_image->gravity=image->gravity; (void) FormatLocaleString(tile_geometry,MagickPathExtent, "%.20gx%.20g+0+0",(double) image->columns,(double) image->rows); flags=ParseGravityGeometry(tile_image,tile_geometry,&geometry,exception); x=(ssize_t) (geometry.x+border_width); y=(ssize_t) (geometry.y+border_width); if ((montage_info->frame != (char *) NULL) && (bevel_width > 0)) { FrameInfo frame_clone; Image *frame_image; /* Put an ornamental border around this tile. */ frame_clone=frame_info; frame_clone.width=width+2*frame_info.width; frame_clone.height=height+2*frame_info.height; value=GetImageProperty(image,"label",exception); if (value != (const char *) NULL) frame_clone.height+=(size_t) ((metrics.ascent-metrics.descent+4)* MultilineCensus(value)); frame_image=FrameImage(image,&frame_clone,image->compose,exception); if (frame_image != (Image *) NULL) { image=DestroyImage(image); image=frame_image; } x=0; y=0; } if (LocaleCompare(image->magick,"NULL") != 0) { /* Composite background with tile. */ if (montage_info->shadow != MagickFalse) { Image *shadow_image; /* Shadow image. */ (void) QueryColorCompliance("#0000",AllCompliance, &image->background_color,exception); shadow_image=ShadowImage(image,80.0,2.0,5,5,exception); if (shadow_image != (Image *) NULL) { (void) CompositeImage(shadow_image,image,OverCompositeOp, MagickTrue,0,0,exception); image=DestroyImage(image); image=shadow_image; } } (void) CompositeImage(montage,image,image->compose,MagickTrue, x_offset+x,y_offset+y,exception); value=GetImageProperty(image,"label",exception); if (value != (const char *) NULL) { /* Annotate composite tile with label. */ (void) FormatLocaleString(tile_geometry,MagickPathExtent, "%.20gx%.20g%+.20g%+.20g",(double) ((montage_info->frame ? image->columns : width)-2*border_width),(double) (metrics.ascent-metrics.descent+4)*MultilineCensus(value), (double) (x_offset+border_width),(double) ((montage_info->frame ? y_offset+height+border_width+4 : y_offset+extract_info.height+border_width+ (montage_info->shadow != MagickFalse ? 4 : 0))+bevel_width)); (void) CloneString(&draw_info->geometry,tile_geometry); (void) CloneString(&draw_info->text,value); (void) AnnotateImage(montage,draw_info,exception); } } x_offset+=(ssize_t) (width+2*(extract_info.x+border_width)); if (((tile+1) == (ssize_t) tiles_per_page) || (((tile+1) % tiles_per_row) == 0)) { x_offset=extract_info.x; y_offset+=(ssize_t) (height+(extract_info.y+border_width)*2+ (metrics.ascent-metrics.descent+4)*number_lines+ (montage_info->shadow != MagickFalse ? 4 : 0)); max_height=0; } if (images->progress_monitor != (MagickProgressMonitor) NULL) { proceed=SetImageProgress(image,MontageImageTag,tiles,total_tiles); if (proceed == MagickFalse) status=MagickFalse; } image_list[tile]=DestroyImage(image_list[tile]); image=DestroyImage(image); tiles++; } (void) status; if ((i+1) < (ssize_t) images_per_page) { /* Allocate next image structure. */ AcquireNextImage(clone_info,montage,exception); if (GetNextImageInList(montage) == (Image *) NULL) { montage=DestroyImageList(montage); return((Image *) NULL); } montage=GetNextImageInList(montage); montage->background_color=montage_info->background_color; image_list+=tiles_per_page; number_images-=tiles_per_page; } } tile_image=DestroyImage(tile_image); if (texture != (Image *) NULL) texture=DestroyImage(texture); title=DestroyString(title); master_list=(Image **) RelinquishMagickMemory(master_list); draw_info=DestroyDrawInfo(draw_info); clone_info=DestroyImageInfo(clone_info); return(GetFirstImageInList(montage)); }