IPv4Layer::IPv4Layer(const IPv4Address& srcIP, const IPv4Address& dstIP) { initLayer(); iphdr* ipHdr = getIPv4Header(); ipHdr->ipSrc = srcIP.toInt(); ipHdr->ipDst = dstIP.toInt(); }
static void msContourLayerInfoInitialize(layerObj *layer) { contourLayerInfo *clinfo = (contourLayerInfo *) layer->layerinfo; if (clinfo != NULL) return; clinfo = (contourLayerInfo *) msSmallCalloc(1,sizeof(contourLayerInfo)); layer->layerinfo = clinfo; clinfo->hOrigDS = NULL; clinfo->hDS = NULL; clinfo->extent.minx = -1.0; clinfo->extent.miny = -1.0; clinfo->extent.maxx = -1.0; clinfo->extent.maxy = -1.0; initLayer(&clinfo->ogrLayer, layer->map); clinfo->ogrLayer.type = layer->type; clinfo->ogrLayer.debug = layer->debug; clinfo->ogrLayer.connectiontype = MS_OGR; clinfo->ogrLayer.name = msStrdup(layer->name); clinfo->ogrLayer.connection = (char*)msSmallMalloc(strlen(clinfo->ogrLayer.name)+13); sprintf(clinfo->ogrLayer.connection, "__%s_CONTOUR__", clinfo->ogrLayer.name); clinfo->ogrLayer.units = layer->units; }
layerObj *layerObj_clone(layerObj *layer) { layerObj *dstLayer; dstLayer = (layerObj *)malloc(sizeof(layerObj)); initLayer(dstLayer, layer->map); msCopyLayer(dstLayer, layer); }
bool PVEFightResultLayer::init() { bool bRet=false; do { initLayer(); bRet=true; } while (0); return bRet; }
/********************************************************************** * class extensions for layerObj, always within the context of a map **********************************************************************/ layerObj *layerObj_new(mapObj *map) { if(msGrowMapLayers(map) == NULL) return(NULL); if(initLayer((map->layers[map->numlayers]), map) == -1) return(NULL); map->layers[map->numlayers]->index = map->numlayers; //Update the layer order list with the layer's index. map->layerorder[map->numlayers] = map->numlayers; map->numlayers++; return (map->layers[map->numlayers-1]); }
bool PortRepairLayer::init() { bool bRet=false; do { if (!Layer::init()) { break; } initLayer(); initContainer(); bRet=true; } while(0); return bRet; }
bool MainLayer::init() { if (!Layer::init()) return false; _angle = 0.0f; auto dispatcher = Director::getInstance()->getEventDispatcher(); auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouches(true); listener->onTouchBegan = CC_CALLBACK_2(MainLayer::onTouchBegan, this); listener->onTouchMoved = CC_CALLBACK_2(MainLayer::onTouchMoved, this); listener->onTouchEnded = CC_CALLBACK_2(MainLayer::onTouchEnded, this); dispatcher->addEventListenerWithSceneGraphPriority(listener, this); initLayer(); return true; }
int msEmbedScalebar(mapObj *map, imageObj *img) { int l,index,s; pointObj point; imageObj *image = NULL; rendererVTableObj *renderer = MS_MAP_RENDERER(map); symbolObj *embededSymbol; if( ! renderer ) { msSetError(MS_MISCERR,"unsupported outputformat","msEmbedScalebar()"); return MS_FAILURE; } index = msGetSymbolIndex(&(map->symbolset), "scalebar", MS_FALSE); if(index != -1) msRemoveSymbol(&(map->symbolset), index); /* remove cached symbol in case the function is called multiple times with different zoom levels */ if((embededSymbol=msGrowSymbolSet(&map->symbolset)) == NULL) return MS_FAILURE; s = map->symbolset.numsymbols; map->symbolset.numsymbols++; image = msDrawScalebar(map); if(!image) { return MS_FAILURE; } embededSymbol->pixmap_buffer = calloc(1,sizeof(rasterBufferObj)); MS_CHECK_ALLOC(embededSymbol->pixmap_buffer, sizeof(rasterBufferObj), MS_FAILURE); if(MS_SUCCESS != renderer->getRasterBufferCopy(image,embededSymbol->pixmap_buffer)) { return MS_FAILURE; } embededSymbol->type = MS_SYMBOL_PIXMAP; /* intialize a few things */ embededSymbol->name = msStrdup("scalebar"); embededSymbol->sizex = embededSymbol->pixmap_buffer->width; embededSymbol->sizey = embededSymbol->pixmap_buffer->height; if(map->scalebar.transparent) { embededSymbol->transparent = MS_TRUE; embededSymbol->transparentcolor = 0; } switch(map->scalebar.position) { case(MS_LL): point.x = MS_NINT(embededSymbol->pixmap_buffer->width/2.0); point.y = map->height - MS_NINT(embededSymbol->pixmap_buffer->height/2.0); break; case(MS_LR): point.x = map->width - MS_NINT(embededSymbol->pixmap_buffer->width/2.0); point.y = map->height - MS_NINT(embededSymbol->pixmap_buffer->height/2.0); break; case(MS_LC): point.x = MS_NINT(map->width/2.0); point.y = map->height - MS_NINT(embededSymbol->pixmap_buffer->height/2.0); break; case(MS_UR): point.x = map->width - MS_NINT(embededSymbol->pixmap_buffer->width/2.0); point.y = MS_NINT(embededSymbol->pixmap_buffer->height/2.0); break; case(MS_UL): point.x = MS_NINT(embededSymbol->pixmap_buffer->width/2.0); point.y = MS_NINT(embededSymbol->pixmap_buffer->height/2.0); break; case(MS_UC): point.x = MS_NINT(map->width/2.0); point.y = MS_NINT(embededSymbol->pixmap_buffer->height/2.0); break; } l = msGetLayerIndex(map, "__embed__scalebar"); if(l == -1) { if (msGrowMapLayers(map) == NULL) return(-1); l = map->numlayers; map->numlayers++; if(initLayer((GET_LAYER(map, l)), map) == -1) return(-1); GET_LAYER(map, l)->name = msStrdup("__embed__scalebar"); GET_LAYER(map, l)->type = MS_LAYER_POINT; if (msGrowLayerClasses( GET_LAYER(map, l) ) == NULL) return(-1); if(initClass(GET_LAYER(map, l)->class[0]) == -1) return(-1); GET_LAYER(map, l)->numclasses = 1; /* so we make sure to free it */ /* update the layer order list with the layer's index. */ map->layerorder[l] = l; } GET_LAYER(map, l)->status = MS_ON; if(map->scalebar.postlabelcache) { /* add it directly to the image */ if(msMaybeAllocateClassStyle(GET_LAYER(map, l)->class[0], 0)==MS_FAILURE) return MS_FAILURE; GET_LAYER(map, l)->class[0]->styles[0]->symbol = s; msDrawMarkerSymbol(&map->symbolset, img, &point, GET_LAYER(map, l)->class[0]->styles[0], 1.0); } else { if(!GET_LAYER(map, l)->class[0]->labels) {
void NodeCom::initWithMap(rapidjson::Value& value) { auto visibleSize=Director::getInstance()->getVisibleSize(); node=cocos2d::Node::create(); if (value.HasMember("contentSize")) { auto size=cocos2d::SizeFromString(value["contentSize"].GetString()); if (size.width<0) size.width=visibleSize.width; if (size.height<0) size.height=visibleSize.height; node->setContentSize(size); } else { node->setContentSize(visibleSize); } if (value.HasMember("anchorPoint")) { node->setAnchorPoint(cocos2d::PointFromString(value["anchorPoint"].GetString())); } cocos2d::Point position=value.HasMember("position")?cocos2d::PointFromString(value["position"].GetString()):cocos2d::Point::ZERO; if (value.HasMember("anchor")) { node->setPosition(getRealPosition(cocos2d::Director::getInstance()->getVisibleSize(), position, cocos2d::PointFromString(value["anchor"].GetString()))); } else if (value.HasMember("position")) { node->setPosition(cocos2d::PointFromString(value["position"].GetString())); } if (value.HasMember("Node")) { int count=value["Node"].Size(); for (int i=0; i<count; i++) { rapidjson::Value& nodeValue=value["Node"][i]; if (!nodeValue.IsNull()&&nodeValue.HasMember("type")) { const char* type=nodeValue["type"].GetString(); cocos2d::Node* child=nullptr; if (strcmp("Label", type)==0) { child=initLabel(nodeValue); } else if (strcmp("Sprite", type)==0) { child=initSprite(nodeValue); } else if (strcmp("Layer", type)==0) { child=initLayer(nodeValue); } else if (strcmp("Button", type)==0) { child=initButton(nodeValue); } else if (strcmp("TableView", type)==0){ child=initTable(nodeValue); } else if (strcmp("ProgressTimer", type)==0){ child=initTimer(nodeValue); } if (child!=nullptr) { node->addChild(child); if (nodeValue.HasMember("name")) { const char* name= nodeValue["name"].GetString(); __nodeNames.insert(std::make_pair(name, child)); } if (nodeValue.HasMember("scale")) { cocos2d::Point point=cocos2d::PointFromString(nodeValue["scale"].GetString()); child->setScale(point.x, point.y); } if (nodeValue.HasMember("position")) { child->setPosition(cocos2d::PointFromString(nodeValue["position"].GetString())); } if (nodeValue.HasMember("anchorPoint")) { child->setAnchorPoint(cocos2d::PointFromString(nodeValue["anchorPoint"].GetString())); } if (nodeValue.HasMember("localZOrder")) { child->setLocalZOrder(nodeValue["localZOrder"].GetInt()); } if (nodeValue.HasMember("globalOrder")) { child->setGlobalZOrder(nodeValue["globalOrder"].GetInt()); } if (nodeValue.HasMember("visible")) { child->setVisible(nodeValue["visible"].GetBool()); } if (nodeValue.HasMember("tag")) { child->setTag(nodeValue["tag"].GetInt()); } //如果声明了anchor,则按照新的规则布局 cocos2d::Point position1=nodeValue.HasMember("position")? cocos2d::PointFromString(nodeValue["position"].GetString()):cocos2d::Point::ZERO; if (nodeValue.HasMember("anchor")) { child->setPosition(getRealPosition(node->getContentSize(), position1, cocos2d::PointFromString(nodeValue["anchor"].GetString()))); } else if (nodeValue.HasMember("position")) { child->setPosition(position1); } } } } } }
IPv4Layer::IPv4Layer() { initLayer(); }
KisImportExportFilter::ConversionStatus KisXCFImport::loadFromDevice(QIODevice* device, KisDocument* doc) { dbgFile << "Start decoding file"; // Read the file into memory device->open(QIODevice::ReadOnly); QByteArray data = device->readAll(); xcf_file = (uint8_t*)data.data(); xcf_length = data.size(); device->close(); // Decode the data getBasicXcfInfo() ; initColormap(); dbgFile << XCF.version << "width = " << XCF.width << "height = " << XCF.height << "layers = " << XCF.numLayers; // Create the image KisImageSP image = new KisImage(doc->createUndoStore(), XCF.width, XCF.height, KoColorSpaceRegistry::instance()->rgb8(), "built image"); QVector<Layer> layers; uint maxDepth = 0; // Read layers for (int i = 0; i < XCF.numLayers; ++i) { Layer layer; xcfLayer& xcflayer = XCF.layers[i]; dbgFile << i << " name = " << xcflayer.name << " opacity = " << xcflayer.opacity << "group:" << xcflayer.isGroup << xcflayer.pathLength; dbgFile << ppVar(xcflayer.dim.width) << ppVar(xcflayer.dim.height) << ppVar(xcflayer.dim.tilesx) << ppVar(xcflayer.dim.tilesy) << ppVar(xcflayer.dim.ntiles) << ppVar(xcflayer.dim.c.t) << ppVar(xcflayer.dim.c.l) << ppVar(xcflayer.dim.c.r) << ppVar(xcflayer.dim.c.b); maxDepth = qMax(maxDepth, xcflayer.pathLength); bool isRgbA = false; // Select the color space const KoColorSpace* colorSpace = 0; switch (xcflayer.type) { case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE: case GIMP_RGB_IMAGE: case GIMP_RGBA_IMAGE: colorSpace = KoColorSpaceRegistry::instance()->rgb8(); isRgbA = true; break; case GIMP_GRAY_IMAGE: case GIMP_GRAYA_IMAGE: colorSpace = KoColorSpaceRegistry::instance()->colorSpace(GrayAColorModelID.id(), Integer8BitsColorDepthID.id(), ""); isRgbA = false; break; } // Create the layer KisLayerSP kisLayer; if (xcflayer.isGroup) { kisLayer = new KisGroupLayer(image, QString::fromUtf8(xcflayer.name), xcflayer.opacity); } else { kisLayer = new KisPaintLayer(image, QString::fromUtf8(xcflayer.name), xcflayer.opacity, colorSpace); } // Set some properties kisLayer->setCompositeOpId(layerModeG2K(xcflayer.mode)); kisLayer->setVisible(xcflayer.isVisible); kisLayer->disableAlphaChannel(xcflayer.mode != GIMP_NORMAL_MODE); layer.layer = kisLayer; layer.depth = xcflayer.pathLength; // Copy the data in the image initLayer(&xcflayer); int left = xcflayer.dim.c.l; int top = xcflayer.dim.c.t; if (!xcflayer.isGroup) { // Copy the data; for (unsigned int x = 0; x < xcflayer.dim.width; x += TILE_WIDTH) { for (unsigned int y = 0; y < xcflayer.dim.height; y += TILE_HEIGHT) { rect want; want.l = x + left; want.t = y + top; want.b = want.t + TILE_HEIGHT; want.r = want.l + TILE_WIDTH; Tile* tile = getMaskOrLayerTile(&xcflayer.dim, &xcflayer.pixels, want); KisHLineIteratorSP it = kisLayer->paintDevice()->createHLineIteratorNG(x, y, TILE_WIDTH); rgba* data = tile->pixels; for (int v = 0; v < TILE_HEIGHT; ++v) { if (isRgbA) { // RGB image do { KoBgrTraits<quint8>::setRed(it->rawData(), GET_RED(*data)); KoBgrTraits<quint8>::setGreen(it->rawData(), GET_GREEN(*data)); KoBgrTraits<quint8>::setBlue(it->rawData(), GET_BLUE(*data)); KoBgrTraits<quint8>::setOpacity(it->rawData(), quint8(GET_ALPHA(*data)), 1); ++data; } while (it->nextPixel()); } else { // Grayscale image do { it->rawData()[0] = GET_RED(*data); it->rawData()[1] = GET_ALPHA(*data); ++data; } while (it->nextPixel()); } it->nextRow(); } } } // Move the layer to its position kisLayer->paintDevice()->setX(left); kisLayer->paintDevice()->setY(top); } // Create the mask if (xcflayer.hasMask) { KisTransparencyMaskSP mask = new KisTransparencyMask(); layer.mask = mask; mask->initSelection(kisLayer); for (unsigned int x = 0; x < xcflayer.dim.width; x += TILE_WIDTH) { for (unsigned int y = 0; y < xcflayer.dim.height; y += TILE_HEIGHT) { rect want; want.l = x + left; want.t = y + top; want.b = want.t + TILE_HEIGHT; want.r = want.l + TILE_WIDTH; Tile* tile = getMaskOrLayerTile(&xcflayer.dim, &xcflayer.mask, want); KisHLineIteratorSP it = mask->paintDevice()->createHLineIteratorNG(x, y, TILE_WIDTH); rgba* data = tile->pixels; for (int v = 0; v < TILE_HEIGHT; ++v) { do { it->rawData()[0] = GET_ALPHA(*data); ++data; } while (it->nextPixel()); it->nextRow(); } } } mask->paintDevice()->setX(left); mask->paintDevice()->setY(top); image->addNode(mask, kisLayer); } dbgFile << xcflayer.pixels.tileptrs; layers.append(layer); } for (int i = 0; i <= maxDepth; ++i) { addLayers(layers, image, i); } doc->setCurrentImage(image); return KisImportExportFilter::OK; }
void complete_flatspec(struct FlattenSpec *spec, guesser guess_callback) { unsigned i ; int anyPartial ; /* Find the layers to convert. */ if( spec->numLayers == 0 ) { spec->layers = XCF.layers ; spec->numLayers = XCF.numLayers ; } else { for( i=0; i<spec->numLayers; i++ ) { GimpLayerModeEffects mode ; int opacity, hasMask ; unsigned j ; for( j=0; ; j++ ) { if( j == XCF.numLayers ) FatalGeneric(22,_("The image has no layer called '%s'"), spec->layers[i].name); if( strcmp(spec->layers[i].name,XCF.layers[j].name) == 0 ) break ; } mode = spec->layers[i].mode == (GimpLayerModeEffects)-1 ? XCF.layers[j].mode : spec->layers[i].mode ; opacity = spec->layers[i].opacity == 9999 ? XCF.layers[j].opacity : spec->layers[i].opacity ; hasMask = spec->layers[i].hasMask == -1 ? XCF.layers[j].hasMask : spec->layers[i].hasMask ; if( hasMask && !XCF.layers[j].hasMask && XCF.layers[j].mask.hierarchy == 0 ) FatalGeneric(22,_("Layer '%s' has no layer mask to enable"), spec->layers[i].name); spec->layers[i] = XCF.layers[j] ; spec->layers[i].mode = mode ; spec->layers[i].opacity = opacity ; spec->layers[i].hasMask = hasMask ; spec->layers[i].isVisible = 1 ; } } /* Force the mode of the lowest visible layer to be Normal or Dissolve. * That may not be logical, but the Gimp does it */ for( i=0; i < spec->numLayers; i++ ) { if( spec->layers[i].isVisible ) { if( spec->layers[i].mode != GIMP_DISSOLVE_MODE ) spec->layers[i].mode = GIMP_NORMAL_MODE ; break ; } } /* Mimic the Gimp's behavior on indexed layers */ if( XCF.type == GIMP_INDEXED && spec->gimpish_indexed ) { for( i=0; i<spec->numLayers; i++ ) if( spec->layers[i].mode != GIMP_DISSOLVE_MODE ) spec->layers[i].mode = GIMP_NORMAL_NOPARTIAL_MODE ; } else spec->gimpish_indexed = 0 ; /* compute dimensions of the window */ if( spec->window_mode == AUTOCROP ) { int first = 1 ; for( i=0; i<spec->numLayers; i++ ) if( spec->layers[i].isVisible ) { computeDimensions(&spec->layers[i].dim) ; if( first ) { spec->dim = spec->layers[i].dim ; first = 0 ; } else { if( spec->dim.c.l < spec->layers[i].dim.c.l ) spec->dim.c.l = spec->layers[i].dim.c.l ; if( spec->dim.c.r > spec->layers[i].dim.c.r ) spec->dim.c.r = spec->layers[i].dim.c.r ; if( spec->dim.c.t < spec->layers[i].dim.c.t ) spec->dim.c.t = spec->layers[i].dim.c.t ; if( spec->dim.c.b > spec->layers[i].dim.c.b ) spec->dim.c.b = spec->layers[i].dim.c.b ; } } if( first ) { spec->window_mode = USE_CANVAS ; } else { spec->dim.width = spec->dim.c.r - spec->dim.c.l ; spec->dim.height = spec->dim.c.b - spec->dim.c.t ; } } if( spec->window_mode != AUTOCROP ) { if( (spec->window_mode & MANUAL_OFFSET) == 0 ) spec->dim.c.t = spec->dim.c.l = 0 ; if( (spec->window_mode & MANUAL_CROP) == 0 ) { spec->dim.height = XCF.height ; spec->dim.width = XCF.width ; } } computeDimensions(&spec->dim); /* We can't handle negative coordinates properly, so abort rather than * crash chaotically. See CVE-2009-217; Debian bug #533361. */ if( spec->dim.c.t < 0 || spec->dim.c.l < 0 ) { FatalUnsupportedXCF("This version cannot extract pixels above or to the " "left of the canvas"); } /* Turn off layers that we don't hit at all */ for( i=0; i<spec->numLayers; i++ ) if( spec->layers[i].isVisible && disjointRects(spec->dim.c,spec->layers[i].dim.c) ) spec->layers[i].isVisible = 0 ; /* See if there is a completely covering layer somewhere in the stack */ /* Also check if partial transparency is possible */ anyPartial = 0 ; for( i=spec->numLayers; i-- ; ) { if( !spec->layers[i].isVisible ) continue ; if( typeHasTransparency(spec->layers[i].type) ) { if( spec->layers[i].mode == GIMP_NORMAL_MODE ) anyPartial = 1; } else if( isSubrect(spec->dim.c,spec->layers[i].dim.c) && (spec->layers[i].mode == GIMP_NORMAL_MODE || spec->layers[i].mode == GIMP_NORMAL_NOPARTIAL_MODE || spec->layers[i].mode == GIMP_DISSOLVE_MODE) ) { /* This layer fills out the entire image. * Turn off anly lower layers, and note that we cannot have * transparency at all. */ while(i) spec->layers[--i].isVisible = 0 ; if( spec->default_pixel != FORCE_ALPHA_CHANNEL ) spec->default_pixel = NEWALPHA(colormap[0],255); anyPartial = 0 ; break ; } } if( spec->partial_transparency_mode == ALLOW_PARTIAL_TRANSPARENCY && (!anyPartial || ALPHA(spec->default_pixel) >= 128) ) spec->partial_transparency_mode = PARTIAL_TRANSPARENCY_IMPOSSIBLE ; /* Initialize layers and print overview if we're verbose */ for( i=spec->numLayers; i--; ) if( spec->layers[i].isVisible ) { initLayer(&spec->layers[i]) ; if( verboseFlag ) { fprintf(stderr,"%dx%d%+d%+d %s %s", spec->layers[i].dim.width, spec->layers[i].dim.height, spec->layers[i].dim.c.l - spec->dim.c.l, spec->layers[i].dim.c.t - spec->dim.c.t, _(showGimpImageType(spec->layers[i].type)), _(showGimpLayerModeEffects(spec->layers[i].mode))); if( spec->layers[i].opacity < 255 ) fprintf(stderr,"/%02d%%",spec->layers[i].opacity * 100 / 255); if( XCF.layers[i].hasMask ) fprintf(stderr,_("/mask")); fprintf(stderr," %s\n",spec->layers[i].name); } } /* Resolve color mode unless we wait until we have the entire image */ if( spec->out_color_mode == COLOR_BY_CONTENTS && !spec->process_in_memory ) { if( guess_callback ) spec->out_color_mode = guess_callback(spec,NULL); if( spec->out_color_mode == COLOR_BY_CONTENTS ) spec->out_color_mode = color_by_layers(spec) ; } }