// initialize image data void ImageBase::init (short width, short height) { // if image has to be scaled if (m_scale) { // recalc sizes of image width = calcSize(width); height = calcSize(height); } // if sizes differ if (width != m_size[0] || height != m_size[1]) { if (m_exports > 0) THRWEXCP(ImageHasExports,S_OK); // new buffer size unsigned int newSize = width * height; // if new buffer is larger than previous if (newSize > m_imgSize) { // set new buffer size m_imgSize = newSize; // release previous and create new buffer if (m_image) delete [] m_image; m_image = new unsigned int[m_imgSize]; } // new image size m_size[0] = width; m_size[1] = height; // scale was processed m_scaleChange = false; } }
int32_t C2DColorConverter::getBuffReq(int32_t port, C2DBuffReq *req) { if (!req) return -1; if (port != C2D_INPUT && port != C2D_OUTPUT) return -1; memset(req, 0, sizeof(C2DBuffReq)); if (port == C2D_INPUT) { req->width = mSrcWidth; req->height = mSrcHeight; req->stride = calcStride(mSrcFormat, mSrcWidth); req->sliceHeight = mSrcHeight; req->lumaAlign = calcLumaAlign(mSrcFormat); req->sizeAlign = calcSizeAlign(mSrcFormat); req->size = calcSize(mSrcFormat, mSrcWidth, mSrcHeight); //add bpp? ALOGV("input req->size = %d\n", req->size); } else if (port == C2D_OUTPUT) { req->width = mDstWidth; req->height = mDstHeight; req->stride = calcStride(mDstFormat, mDstWidth); req->sliceHeight = mDstHeight; req->lumaAlign = calcLumaAlign(mDstFormat); req->sizeAlign = calcSizeAlign(mDstFormat); req->size = calcSize(mDstFormat, mDstWidth, mDstHeight); ALOGV("output req->size = %d\n", req->size); } return 0; }
void CanvasNavigator::createCanvasBox() { QRect crect = m_canvas->contentsRect(); QRect mapped = m_canvas->mapDev(crect); QRectF real(calcSize(mapped.x()), 0, calcSize(mapped.width()), 80); m_canvasBox = m_scene->addRect(real); m_canvasBox->setZValue(124000.0f); updateCanvasBoxColor(); }
C2DColorConverter::C2DColorConverter(size_t srcWidth, size_t srcHeight, size_t dstWidth, size_t dstHeight, ColorConvertFormat srcFormat, ColorConvertFormat dstFormat, int32_t flags, size_t stride) { mError = 0; mC2DLibHandle = dlopen("libC2D2.so", RTLD_NOW); if (!mC2DLibHandle) { ALOGE("FATAL ERROR: could not dlopen libc2d2.so: %s", dlerror()); mError = -1; return; } mC2DCreateSurface = (LINK_c2dCreateSurface)dlsym(mC2DLibHandle, "c2dCreateSurface"); mC2DUpdateSurface = (LINK_c2dUpdateSurface)dlsym(mC2DLibHandle, "c2dUpdateSurface"); mC2DReadSurface = (LINK_c2dReadSurface)dlsym(mC2DLibHandle, "c2dReadSurface"); mC2DDraw = (LINK_c2dDraw)dlsym(mC2DLibHandle, "c2dDraw"); mC2DFlush = (LINK_c2dFlush)dlsym(mC2DLibHandle, "c2dFlush"); mC2DFinish = (LINK_c2dFinish)dlsym(mC2DLibHandle, "c2dFinish"); mC2DWaitTimestamp = (LINK_c2dWaitTimestamp)dlsym(mC2DLibHandle, "c2dWaitTimestamp"); mC2DDestroySurface = (LINK_c2dDestroySurface)dlsym(mC2DLibHandle, "c2dDestroySurface"); mC2DMapAddr = (LINK_c2dMapAddr)dlsym(mC2DLibHandle, "c2dMapAddr"); mC2DUnMapAddr = (LINK_c2dUnMapAddr)dlsym(mC2DLibHandle, "c2dUnMapAddr"); if (!mC2DCreateSurface || !mC2DUpdateSurface || !mC2DReadSurface || !mC2DDraw || !mC2DFlush || !mC2DFinish || !mC2DWaitTimestamp || !mC2DDestroySurface || !mC2DMapAddr || !mC2DUnMapAddr) { ALOGE("%s: dlsym ERROR", __FUNCTION__); mError = -1; return; } mSrcWidth = srcWidth; mSrcHeight = srcHeight; mDstWidth = dstWidth; mDstHeight = dstHeight; mSrcFormat = srcFormat; mDstFormat = dstFormat; mSrcSize = calcSize(srcFormat, srcWidth, srcHeight); mDstSize = calcSize(dstFormat, dstWidth, dstHeight); mSrcYSize = calcYSize(srcFormat, srcWidth, srcHeight); mDstYSize = calcYSize(dstFormat, dstWidth, dstHeight); mStride = stride; mFlags = flags; // can be used for rotation mSrcSurfaceDef = getDummySurfaceDef(srcFormat, srcWidth, srcHeight, true); mDstSurfaceDef = getDummySurfaceDef(dstFormat, dstWidth, dstHeight, false); memset((void*)&mBlit,0,sizeof(C2D_OBJECT)); mBlit.source_rect.x = 0 << 16; mBlit.source_rect.y = 0 << 16; mBlit.source_rect.width = srcWidth << 16; mBlit.source_rect.height = srcHeight << 16; mBlit.target_rect.x = 0 << 16; mBlit.target_rect.y = 0 << 16; mBlit.target_rect.width = dstWidth << 16; mBlit.target_rect.height = dstHeight << 16; mBlit.config_mask = C2D_ALPHA_BLEND_NONE | C2D_NO_BILINEAR_BIT | C2D_NO_ANTIALIASING_BIT | C2D_TARGET_RECT_BIT; mBlit.surface_id = mSrcSurface; }
void CanvasNavigator::updateLoopRange() { if(m_punchIn) { double lpos = calcSize(song->lpos()); m_punchIn->setPos(QPointF(lpos, 0.0)); m_punchIn->setVisible(song->loop() || song->punchin()); } if(m_punchOut) { double rpos = calcSize(song->rpos()); m_punchOut->setPos(QPointF(rpos, 0.0)); m_punchOut->setVisible(song->loop() || song->punchout()); } }
bool SaveContainer::writePart(uint32 partN, const SavePart *part) { // Sanity checks if (!part) return false; if (partN >= _partCount) return false; Part *&p = _parts[partN]; delete p; // Create the part p = new Part(part->getSize()); Common::WriteStream *pStream = p->createWriteStream(); // Write if (!part->write(*pStream)) { delete p; p = 0; delete pStream; return false; } delete pStream; // Update size _header.setSize(calcSize()); return true; }
/** * Read the file and form the HTML -> MOVE TO UTILS **/ char* formHTML(struct fileInfo informator) { int len = calcSize(informator); if ((informator.fd = fopen(informator.filename, "rt")) != NULL ) { printf("> File Open Success \n"); // get information regarding the img file if ((strcmp(informator.Context, "Content-Type: image/jpeg\r\n") == 0) || (strcmp(informator.Context, "Content-Type: image/gif\r\n") == 0)) { printf("The size is [%d] \n", len); char* contents = (char*) malloc((sizeof(char) * len) + 1); contents[len + 1] = '\0'; size_t bytes = fread(contents, sizeof(char), len, informator.fd); fclose(informator.fd); return contents; } else { // get info regarding the txt file printf("The size is [%d] \n", len); char* contents = (char*) malloc((sizeof(char) * len) + 2); size_t bytes = fread(contents, sizeof(char), len, informator.fd); contents[len + 2] = '\0'; contents[len + 1] = '\n'; contents[len] = '\r'; fclose(informator.fd); return contents; } } else { printf("file open NOT A SUCCESS \n"); return ""; } }
void IntelHexImage::open(bool read) { if (read) { /* NOTE: "t" mode do nothing on non-Windows platform!!! See also IntelHexImage::read() */ _file = fopen(_name.c_str(), "rt"); if (_file == NULL) throw DEFileOpenFailed(_name, read); _size = calcSize(); } else { /* NOTE: "t" mode do nothing on non-Windows platform!!! See also IntelHexImage::write() */ _file = fopen(_name.c_str(), "wt"); if (_file == NULL) throw DEFileOpenFailed(_name, read); _size = 0; } _read = read; _readCurrent = 0; _readAddr = 0; _writeAddr = 0; _linAddr = 1; // LOW 16 bit MUST be nonzero at first time write() called _record.clear(); }
typename P::Value cache<P>::read(const K & key) { { vespalib::LockGuard guard(_hashLock); if (Lru::hasKey(key)) { _hit++; return (*this)[key]; } else { _miss++; } } vespalib::LockGuard storeGuard(getLock(key)); { vespalib::LockGuard guard(_hashLock); if (Lru::hasKey(key)) { // Somebody else just fetched it ahead of me. _race++; return (*this)[key]; } } V value; if (_store.read(key, value)) { vespalib::LockGuard guard(_hashLock); Lru::insert(key, value); _sizeBytes += calcSize(key, value); _insert++; } else { _noneExisting.fetch_add(1); } return value; }
void TextPreview::setWins(const QList<FF8Window> &windows, bool update) { ff8Windows = windows; if(update) calcSize(); //qDebug() << "type" << window.type << "x" << window.x << "y" << window.y << "u1" << window.u1; }
void TextPreview::setText(const QByteArray &textData, bool reset) { ff8Text = textData; if(reset) currentPage = 0; calcSize(); }
//////////////////////////// // kernel caller definitions bool SURF_OCL::calcLayerDetAndTrace(int octave, int c_layer_rows) { int nOctaveLayers = params->nOctaveLayers; const int min_size = calcSize(octave, 0); const int max_samples_i = 1 + ((img_rows - min_size) >> octave); const int max_samples_j = 1 + ((img_cols - min_size) >> octave); size_t localThreads[] = {16, 16}; size_t globalThreads[] = { divUp(max_samples_j, (int)localThreads[0]) * localThreads[0], divUp(max_samples_i, (int)localThreads[1]) * localThreads[1] * (nOctaveLayers + 2) }; ocl::Kernel kerCalcDetTrace("SURF_calcLayerDetAndTrace", ocl::xfeatures2d::surf_oclsrc, kerOpts); if(haveImageSupport) { kerCalcDetTrace.args(sumTex, img_rows, img_cols, nOctaveLayers, octave, c_layer_rows, ocl::KernelArg::WriteOnlyNoSize(det), ocl::KernelArg::WriteOnlyNoSize(trace)); } else { kerCalcDetTrace.args(ocl::KernelArg::ReadOnlyNoSize(sum), img_rows, img_cols, nOctaveLayers, octave, c_layer_rows, ocl::KernelArg::WriteOnlyNoSize(det), ocl::KernelArg::WriteOnlyNoSize(trace)); } return kerCalcDetTrace.run(2, globalThreads, localThreads, true); }
void Text::setText(String text) { XOJ_CHECK_TYPE(Text); this->text = text; calcSize(); }
EXPORT int mongo_gridfs_store(struct gridfs_* gfs, mxArray* data, char* remoteName, char* contentType) { uint64_t size; void* p; if (mxIsComplex(data)) mexErrMsgTxt("GridFS:store - Complex values not supported"); p = calcSize(data, &size); return (gridfs_store_buffer((gridfs*)gfs, (char*)p, size, remoteName, contentType) == MONGO_OK); }
float TextField2::getMeasuredHeight() { if (mDirty) { calcSize(); } return mMeasuredHeight; }
bool cache<P>::removeOldest(const value_type & v) { bool remove(Lru::removeOldest(v) || (sizeBytes() >= capacityBytes())); if (remove) { _sizeBytes -= calcSize(v.first, v.second._value); } return remove; }
float TextField2::getMeasuredWidth() { if (mDirty) { calcSize(); } return mMeasuredWidth; }
// capture image from viewport void ImageViewport::calcImage (unsigned int texId) { // if scale was changed if (m_scaleChange) // reset image init(m_capSize[0], m_capSize[1]); // if texture wasn't initialized if (!m_texInit) { // initialize it loadTexture(texId, m_image, m_size); m_texInit = true; } // if texture can be directly created if (texId != 0 && m_pyfilter == NULL && m_capSize[0] == calcSize(m_capSize[0]) && m_capSize[1] == calcSize(m_capSize[1]) && !m_flip) { // just copy current viewport to texture glBindTexture(GL_TEXTURE_2D, texId); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1]); // image is not available m_avail = false; } // otherwise copy viewport to buffer, if image is not available else if (!m_avail) { // get frame buffer data if (m_alpha) { glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGBA, GL_UNSIGNED_BYTE, m_viewportImage); // filter loaded data FilterRGBA32 filt; filterImage(filt, m_viewportImage, m_capSize); } else { glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGB, GL_UNSIGNED_BYTE, m_viewportImage); // filter loaded data FilterRGB24 filt; filterImage(filt, m_viewportImage, m_capSize); } } }
void RangeSensorWidget::setGroup(CORBA::UShort _group) { group_ = _group; scan_ = sensor_->getGroup(group_); calcSize(); if (!timer_) timer_ = startTimer(40); calcCaption(); }
void Area::insert(size_t dimOrdinal, const Set* elems, bool calc) { if (dimOrdinal >= area.size()) { throw ErrorException(ErrorException::ERROR_INTERNAL, "Area::insert invalid dimOrdinal"); } area[dimOrdinal] = elems; if (calc) { calcSize(); } }
void ScaleBar::pointerButtonDown(GLMotif::Event& event) { Scalar newScale=currentScale; /* Check if the event happened in the left or right corner: */ float relEventPos=(event.getWidgetPoint().getPoint()[0]-getInterior().origin[0])/getInterior().size[0]; if(relEventPos<=0.333f) { /* Calculate the next smaller quasi-binary scale factor: */ newScale=Scalar(getSmallerQuasiBinary(currentScale)); } else if(relEventPos>=0.667f) { /* Calculate the next bigger quasi-binary scale factor: */ newScale=Scalar(getBiggerQuasiBinary(currentScale)); } if(newScale!=currentScale&&activateNavigationTool(reinterpret_cast<const Tool*>(this))) { /* Adjust the navigation transformation: */ Scalar newNavScale; const Geometry::LinearUnit& unit=getCoordinateManager()->getUnit(); if(unit.isImperial()) { /* Calculate scale factor through imperial units: */ newNavScale=getInchFactor()*newScale/unit.getInchFactor(); } else { /* Calculate scale factor through metric units: */ newNavScale=getMeterFactor()*newScale/unit.getMeterFactor(); } /* Get the current navigation transformation and calculate the display center position in navigation coordinates: */ const NavTransform& nav=getNavigationTransformation(); Point center=nav.inverseTransform(getDisplayCenter()); /* Create the new navigation transformation: */ NavTransform newNav=NavTransform(nav.getTranslation(),nav.getRotation(),newNavScale); newNav.leftMultiply(NavTransform::translate(getDisplayCenter()-newNav.transform(center))); setNavigationTransformation(newNav); deactivateNavigationTool(reinterpret_cast<const Tool*>(this)); currentScale=newScale; /* Update the scale bar: */ calcSize(newNav); /* Resize the widget so that the clicked point stays in the same place: */ GLMotif::Vector newSize=calcNaturalSize(); GLfloat newInteriorWidth=newSize[0]-2.0f*getBorderWidth(); GLfloat newOrigin=event.getWidgetPoint().getPoint()[0]-newInteriorWidth*relEventPos-getBorderWidth(); resize(GLMotif::Box(GLMotif::Vector(newOrigin,0.0f,0.0f),newSize)); } }
double Element::getY() { XOJ_CHECK_TYPE(Element); if (!this->sizeCalculated) { this->sizeCalculated = true; calcSize(); } return y; }
void cache<P>::invalidate(const vespalib::LockGuard & guard, const K & key) { assert(guard.locks(_hashLock)); (void) guard; if (Lru::hasKey(key)) { _sizeBytes -= calcSize(key, (*this)[key]); _invalidate++; Lru::erase(key); } }
double Element::getElementWidth() { XOJ_CHECK_TYPE(Element); if (!this->sizeCalculated) { this->sizeCalculated = true; calcSize(); } return this->width; }
void DataDescriptor::forEach(std::function<void(const char*, const char*, int)> func) { const char* p = mDescriptor.c_str(); const char* type_start; int type_size; const char* name_start; int name_size; int index = 0; while (*p) { while (std::isspace(*p) || std::ispunct(*p)) { ++p; } type_start = p; if (*p == 0) { break; } while (std::isalnum(*p)) // types are alphanumeric { ++p; } type_size = p - type_start; if (type_size == 0) { break; } std::string type(type_start, type_size); while (std::isspace(*p)) { ++p; } name_start = p; if (*p == '!') // skip leading ! { ++p; // indicates unused field } while (std::isalnum(*p) || (*p == '_') || (*p == '[') || (*p == ']')) { ++p; // names are alphanumeric, _ allowed, [] for arrays } name_size = p - name_start; if (name_size == 0) { break; } std::string name(name_start, name_size); int size = calcSize(type.c_str()); func(name.c_str(), type.c_str(), size); ++index; } }
EXPORT void mongo_gridfile_writer_write(struct gridfile_* gf, mxArray* data) { uint64_t size; void* p; int cplx = mxIsComplex(data); if (cplx && mxGetClassID(data) != mxDOUBLE_CLASS) mexErrMsgTxt("GridfileWriter:write - only complex values of type double are supported"); p = calcSize(data, &size); gridfile_write_buffer((gridfile*)gf, (char*)p, size); if (cplx) gridfile_write_buffer((gridfile*)gf, (char*)mxGetPi(data), size); }
double Element::getElementHeight() { XOJ_CHECK_TYPE(Element); if (!this->sizeCalculated) { this->sizeCalculated = true; calcSize(); } return this->height; }
void CanvasNavigator::updateMarkers() { MarkerList* markers = song->marker(); for (iMarker m = markers->begin(); m != markers->end(); ++m) { QPointF point(calcSize(m->second.tick()), 0.0); QGraphicsRectItem* marker = m_markers.value(m->second.id()); if(marker) marker->setPos(point); } }
void cache<P>::write(const K & key, V value) { size_t newSize = calcSize(key, value); vespalib::LockGuard storeGuard(getLock(key)); { vespalib::LockGuard guard(_hashLock); if (Lru::hasKey(key)) { _sizeBytes -= calcSize(key, (*this)[key]); _update++; } } _store.write(key, value); { vespalib::LockGuard guard(_hashLock); (*this)[key] = std::move(value); _sizeBytes += newSize; _write++; } }
void DataDescriptor::parseDescriptor() { int index = 0; forEach([this, index](const char* name, const char* type, int size) mutable { // check if it is array int array_size = 1; const char* p = name; const char* bracket = strchr(name, '['); size_t namelen = strlen(name); if (name == NULL) { LOGE("UniformBlock: SYNTAX ERROR: expecting uniform name\n"); return; } if (bracket) // parse array size in brackets { namelen = bracket - name; array_size = 0; p += (bracket - name) + 1; while (std::isdigit(*p)) { int v = *p - '0'; array_size = array_size * 10 + v; ++p; } } DataEntry entry; short byteSize = calcSize(type); entry.Type = makeShaderType(type, byteSize); byteSize *= array_size; // multiply by number of array elements entry.IsSet = false; entry.Count = array_size; entry.NotUsed = false; entry.IsInt = strstr(type,"int") != nullptr; entry.IsMatrix = type[0] == 'm'; entry.Index = index++; entry.Offset = mTotalSize; entry.Size = byteSize; if (*name == '!') // ! indicates entry not used by shader { entry.NotUsed = true; ++name; } addName(name, namelen, entry); mLayout.push_back(entry); mTotalSize += entry.Size; }); }