示例#1
0
文件: Skin.cpp 项目: AmesianX/pioneer
void Skin::DrawRectElement(const RectElement &element, const Point &pos, const Point &size, Graphics::BlendMode blendMode) const
{
	Graphics::VertexArray va(Graphics::ATTRIB_POSITION | Graphics::ATTRIB_UV0);

	va.Add(vector3f(pos.x,        pos.y,        0.0f), scaled(vector2f(element.pos.x,                element.pos.y)));
	va.Add(vector3f(pos.x,        pos.y+size.y, 0.0f), scaled(vector2f(element.pos.x,                element.pos.y+element.size.y)));
	va.Add(vector3f(pos.x+size.x, pos.y,        0.0f), scaled(vector2f(element.pos.x+element.size.x, element.pos.y)));
	va.Add(vector3f(pos.x+size.x, pos.y+size.y, 0.0f), scaled(vector2f(element.pos.x+element.size.x, element.pos.y+element.size.y)));

	m_renderer->DrawTriangles(&va, GetRenderState(blendMode), m_textureMaterial.Get(), Graphics::TRIANGLE_STRIP);
}
示例#2
0
void OverlayEditorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
	QGraphicsScene::mouseReleaseEvent(e);

	if (e->isAccepted())
		return;

	if (e->button() == Qt::LeftButton) {
		e->accept();

		QRectF rect = qgriSelected->rect();

		if (! qgpiSelected || (rect == selectedRect())) {
			return;
		}

		QRectF scaled(rect.x() / (uiSize * uiZoom), rect.y() / (uiSize * uiZoom), rect.width() / (uiSize * uiZoom), rect.height() / (uiSize * uiZoom));

		if (qgpiSelected == qgpiMuted) {
			os.qrfMutedDeafened = scaled;
			updateMuted();
		} else if (qgpiSelected == qgpiAvatar) {
			os.qrfAvatar = scaled;
			updateAvatar();
		} else if (qgpiSelected == qgpiChannel) {
			os.qrfChannel = scaled;
			updateChannel();
		} else if (qgpiSelected == qgpiName) {
			os.qrfUserName = scaled;
			updateUserName();
		}

		moveBox();
	}
}
示例#3
0
void CoverUtils::PopulateCache(std::vector<BootablesDb::Bootable> bootables)
{
	m_lock.lock();
	PopulatePlaceholderCover();

	auto coverpath(CAppConfig::GetBasePath() / boost::filesystem::path("covers"));
	Framework::PathUtils::EnsurePathExists(coverpath);

	auto itr = CoverUtils::cache.find("PH");
	auto placeholder_size = itr->second.size();
	for(auto bootable : bootables)
	{
		if(bootable.discId.empty())
			continue;

		auto path = coverpath / (bootable.discId + ".jpg");
		if(boost::filesystem::exists(path))
		{
			auto itr = CoverUtils::cache.find(bootable.discId.c_str());
			if(itr == CoverUtils::cache.end())
			{
				auto pixmap = QPixmap(PathToQString(path));
				pixmap = pixmap.scaled(placeholder_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
				CoverUtils::cache.insert(std::make_pair(bootable.discId.c_str(), pixmap));
			}
		}
	}
	m_lock.unlock();
}
示例#4
0
void IndexedImage::scale( int width, int height )
{
	shared_ptr<IndexedImage> p = dynamic_cast<IndexedImage*>(scaled(width, height).get());
	this->imageDataByte = p->imageDataByte;
	this->width = width;
	this->height = height;
}
示例#5
0
文件: RayTrace.cpp 项目: WesleyTo/as2
Intersect Sphere::intersect(Ray r) {
    Intersect::Intersect ret = *new Intersect::Intersect();
    std::vector<float> d = r.getDir();
    std::vector<float> e = r.getEye();
    std::vector<float> eminusp(3);
    eminusp[0] = e[0] - position[0];
    eminusp[1] = e[1] - position[1];
    eminusp[2] = e[2] - position[2];
    float ddotd = d[0]*d[0]+d[1]*d[1]+d[2]*d[2];
    float empdot = eminusp[0]*eminusp[0] + eminusp[1]*eminusp[1] + eminusp[2]*eminusp[2];
    float ddoteminusp = d[0]*eminusp[0] + d[1]*eminusp[1] + d[2]*eminusp[2];
    float discriminant = sqrt(ddoteminusp * ddoteminusp - ddotd*(empdot - radius*radius));
    if (discriminant >= 0) {
        ret.setHit(true);
        float scalar = -1.0f;
        float * scale = &scalar;
        std::vector<float> scaled(3);
        scaled = vScale(-1, d);
        //scaled[0] = d[0]*(-1);
        //scaled[1] = d[1]*(-1);
        //scaled[2] = d[2]*(-1);
        float sdotemp = scaled[0]*eminusp[0] + scaled[1]*eminusp[1] + scaled[2]*eminusp[2];
        ret.setPoint(r.project((sdotemp+discriminant)/ddotd));
    }
    return ret;
}
/**
\brief      xscaled
\Access    public 
\param  int width
\param  int height
\param  Ws::AspectRatioMode aspectRatioMode
\param  Ws::TransformationMode transformationMode
\retval     WPixmap
\remark     
*/
WPixmap WPixmap::xscaled( int width, int height, Ws::AspectRatioMode aspectRatioMode /*= Ws::IgnoreAspectRatio*/, Ws::TransformationMode transformationMode /*= Ws::FastTransformation*/ ) const
{
	QMatrix m;
	m.scale(width, height);
	return WPixmap(scaled(width, height, static_cast<Qt::AspectRatioMode>(aspectRatioMode), static_cast<Qt::TransformationMode>(transformationMode)));

}
示例#7
0
文件: main.c 项目: conghui/books
static void draw_vertical_histogram(int *word_len, int size)
{
    int *scaled_word_len;
    int i;
    int max;
    int scaled_max;

    scaled_word_len = malloc(size * sizeof *scaled_word_len);
    max = max_value(word_len, size);

    for (i = 0; i < size; i++) {
        scaled_word_len[i] = scaled(word_len[i], max);
    }

    scaled_max = max_value(scaled_word_len, size);
    for (i = scaled_max; i > 0; i--) {
        int j;
        for (j = 1; j < WORD_MAX_LENGTH; j++) {
            if (scaled_word_len[j] >= i) {
                scaled_word_len[j]--;
                printf("%3c", '*');
            }
            else {
                printf("%3c", ' ');
            }
        }
        putchar('\n');
    }

    for (i = 1; i < size; i++) {
        printf("%3d", i);
    }
    putchar('\n');
}
示例#8
0
// Draws the data in a new window.
void ImageData::Display() const {
#ifndef GRAPHICS_DISABLED
  const int kTextSize = 64;
  // Draw the image.
  Pix* pix = GetPix();
  if (pix == NULL) return;
  int width = pixGetWidth(pix);
  int height = pixGetHeight(pix);
  ScrollView* win = new ScrollView("Imagedata", 100, 100,
                                   2 * (width + 2 * kTextSize),
                                   2 * (height + 4 * kTextSize),
                                   width + 10, height + 3 * kTextSize, true);
  win->Image(pix, 0, height - 1);
  pixDestroy(&pix);
  // Draw the boxes.
  win->Pen(ScrollView::RED);
  win->Brush(ScrollView::NONE);
  win->TextAttributes("Arial", kTextSize, false, false, false);
  for (int b = 0; b < boxes_.size(); ++b) {
    boxes_[b].plot(win);
    win->Text(boxes_[b].left(), height + kTextSize, box_texts_[b].string());
    TBOX scaled(boxes_[b]);
    scaled.scale(256.0 / height);
    scaled.plot(win);
  }
  // The full transcription.
  win->Pen(ScrollView::CYAN);
  win->Text(0, height + kTextSize * 2, transcription_.string());
  // Add the features.
  win->Pen(ScrollView::GREEN);
  win->Update();
  window_wait(win);
#endif
}
示例#9
0
Utils::Point2D TextPlot::scalePoint(const Utils::Point2D & point, double scale_factor) {
  // Bouml preserved body begin 00036B85
    Utils::Point2D scaled(point);

    scaled *= scale_factor;
    return scaled;
  // Bouml preserved body end 00036B85
}
示例#10
0
static Area scaleBox(const Area & area, double x, double y){
    Area scaled(area);
    scaled.x1 *= x;
    scaled.x2 *= x;
    scaled.y1 *= y;
    scaled.y2 *= y;
    return scaled;
}
示例#11
0
Bitmap Bitmap::scaleTo(const int width, const int height) const {
    if (width == getWidth() && height == getHeight()){
        return *this;
    }
    Bitmap scaled(width, height);
    this->Stretch(scaled);
    return scaled;
}
示例#12
0
QMargins
DpiScaler::scaled( const QMargins& margins ) const
{
    return scaled( margins.left(),
                   margins.top(),
                   margins.right(),
                   margins.bottom() );
}
示例#13
0
bool    Replacer::replaceFieldInImageWidget( const ImagePtr & widget, const ReportPtr & report, int i )
{
    auto text = widget->getOriginalText();
    auto image = replaceFieldImage( text, report, i );
    auto size = widget->getSize();
    widget->setImage( image.scaled( size ) );

    return true;
}
QImage ScaledScreenBuffer::createImage() const {
    Q_D(const ScaledScreenBuffer);
    auto sourceImage = d->sourceBuffer->createImage();
    if (!sourceImage.isNull()) {
        return sourceImage.scaled(d->scaledSize, Qt::IgnoreAspectRatio,
            Qt::SmoothTransformation);
    }
    return QImage();
}
示例#15
0
QMargins
DpiScaler::scaled( const QPaintDevice* pd, const QMargins& margins )
{
    return scaled( pd,
                   margins.left(),
                   margins.top(),
                   margins.right(),
                   margins.bottom() );
}
void DS325CalibWorker::calibrateAmplitude(cv::Mat& source, cv::Mat& result) {
    cv::Mat scaled;
    cv::resize(source, scaled, _csize);

    cv::Mat cropped = scaled(cv::Rect(40, 43, 498, 498 / 4 * 3)); // TODO
    cv::resize(cropped, cropped, _csize);
    cv::Mat temp;
    cv::remap(cropped, temp, _rectifyMaps[1][0], _rectifyMaps[1][1], CV_INTER_LINEAR);
    cv::resize(temp(validROI[1]), result, _dsize);
}
示例#17
0
void ShaderRenderer::drawTexturedRect2D(const Common::Rect &screenRect, const Common::Rect &textureRect,
		Texture *texture, float transparency, bool additiveBlending) {

	OpenGLTexture *glTexture = static_cast<OpenGLTexture *>(texture);

	const float tLeft = textureRect.left / (float)glTexture->internalWidth;
	const float tWidth = textureRect.width() / (float)glTexture->internalWidth;
	const float tTop = textureRect.top / (float)glTexture->internalHeight;
	const float tHeight = textureRect.height() / (float)glTexture->internalHeight;

	const float sLeft = screenRect.left;
	const float sTop = screenRect.top;
	const float sWidth = screenRect.width();
	const float sHeight = screenRect.height();

	if (transparency >= 0.0) {
		if (additiveBlending) {
			glBlendFunc(GL_SRC_ALPHA, GL_ONE);
		} else {
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		}
		glEnable(GL_BLEND);
	} else {
		transparency = 1.0;
	}

	_boxShader->use();
	_boxShader->setUniform("textured", true);
	_boxShader->setUniform("color", Math::Vector4d(1.0f, 1.0f, 1.0f, transparency));
	_boxShader->setUniform("verOffsetXY", scaled(sLeft, sTop));
	_boxShader->setUniform("verSizeWH", scaled(sWidth, sHeight));
	_boxShader->setUniform("texOffsetXY", Math::Vector2d(tLeft, tTop));
	_boxShader->setUniform("texSizeWH", Math::Vector2d(tWidth, tHeight));

	glDepthMask(GL_FALSE);

	glBindTexture(GL_TEXTURE_2D, glTexture->id);

	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

	glDisable(GL_BLEND);
	glDepthMask(GL_TRUE);
}
示例#18
0
QPixmap ItemBase::getResultContactAvatar(int width, int height) const {
	if (_result->_type == Result::Type::Contact) {
		auto result = EmptyUserpic(qHash(_result->_id) % kUserColorsCount, _result->getLayoutTitle()).generate(width);
		if (result.height() != height * cIntRetinaFactor()) {
			result = result.scaled(QSize(width, height) * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
		}
		return result;
	}
	return QPixmap();
}
示例#19
0
 //-----------------------------------------------------------------------------
 const ColourValue AutoParamDataSource::getLightSpecularColourWithPower(size_t index) const
 {
     const Light& l = getLight(index);
     ColourValue scaled(l.getSpecularColour());
     Real power = l.getPowerScale();
     // scale, but not alpha
     scaled.r *= power;
     scaled.g *= power;
     scaled.b *= power;
     return scaled;
 }
示例#20
0
QRectF PathView::contentsSceneRect() const
{
	qreal scale = mapScale(_zoom);
	QRectF br = scaled(_tr | _rr | _wr, 1.0/scale);

	if (br.isNull())
		return QRectF(QPointF(_wp.x() / scale - Tile::size()/2,
		  _wp.y() /scale - Tile::size()/2), QSizeF(Tile::size(), Tile::size()));
	else
		return br.adjusted(-Tile::size(), -Tile::size(), Tile::size(),
		  Tile::size());
}
示例#21
0
QSizeF WindowController::getMinSize() const
{
    if (_targetIsFullscreen())
    {
        const auto size = _getPreferredDimensions();
        const auto targetSize = size.scaled(_group.size(), Qt::KeepAspectRatio);
        return std::min(targetSize, getMaxSize());
    }

    const auto minContentSize = QSizeF{_window.getContent().getMinDimensions()};
    const auto minSize = QSizeF{ui::getMinWindowSize(), ui::getMinWindowSize()};
    return std::max(minContentSize, minSize);
}
示例#22
0
void ShaderRenderer::drawRect2D(const Common::Rect &rect, uint32 color) {
	uint8 a, r, g, b;
	Graphics::colorToARGB< Graphics::ColorMasks<8888> >(color, a, r, g, b);

	_boxShader->use();
	_boxShader->setUniform("textured", false);
	_boxShader->setUniform("color", Math::Vector4d(r / 255.0, g / 255.0, b / 255.0, a / 255.0));
	_boxShader->setUniform("verOffsetXY", scaled(rect.left, rect.top));
	_boxShader->setUniform("verSizeWH", scaled(rect.width(), rect.height()));

	glDepthMask(GL_FALSE);

	if (a != 255) {
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	}

	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

	glDisable(GL_BLEND);
	glDepthMask(GL_TRUE);
}
示例#23
0
static QPixmap scalePixmap( const QPixmap& pm, int w, int h )
{
#if QT_VERSION >= 0x030200
	QPixmap result( 20, 20, pm.depth() );
	result.setMask( QBitmap( 20, 20, true ) );
	QPixmap scaled( pm.convertToImage().smoothScale( w, h ) );
	copyBlt( &result, (20 - w) / 2, (20 - h) / 2, &scaled, 0, 0, w, h );
	return result;
#else
	Q_UNUSED(w);
	Q_UNUSED(h);
	return pm;
#endif
}
	void KviCanvasPolygon::resetPoints()
	{
		QPointArray scaled(m_points.size());
		for(unsigned int i=0;i<m_points.size();i++)
		{
			int px;
			int py;
			m_points.point(i,&px,&py);
			px = (int)(px * m_dScaleFactor);
			py = (int)(py * m_dScaleFactor);
			scaled.setPoint(i,px,py);
		}
		setPoints(scaled);
	}
void findChessboards(cv::Mat& color, cv::Mat& amplitude) {
    #define MAX_DEPTH 1000
    #define MIN_DEPTH 0
    static int imageNum = 0;

    cv::Mat scaled(amplitude.rows * 2, amplitude.cols * 2, CV_16UC1);

    cv::Mat maxDist = cv::Mat::ones(color.rows, color.cols, CV_16UC1) * MAX_DEPTH;
    cv::Mat minDist = cv::Mat::ones(color.rows, color.cols, CV_16UC1) * MIN_DEPTH;
    cv::resize(amplitude, scaled, color.size());
    cv::min(scaled, maxDist, scaled);

    cv::Size patternSize = cv::Size(9, 6);
    std::vector<cv::Point2f> imagePoints[2];

    scaled -= minDist;
    scaled.convertTo(scaled, CV_8UC1, 255.0 / (MAX_DEPTH - MIN_DEPTH));

    if (cv::findChessboardCorners(
            color, patternSize, imagePoints[0],
            CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE) &&
        cv::findChessboardCorners(
                scaled, patternSize, imagePoints[1],
                CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE)) {
        if (cv::waitKey(1) == 't') {
            std::stringstream cs, as;
            cs << FLAGS_dir << "/color_" << imageNum << FLAGS_suffix;
            as << FLAGS_dir << "/depth_" << imageNum << FLAGS_suffix;

            cv::imwrite(cs.str(), color);
            cv::imwrite(as.str(), amplitude);

            std::cout << cs.str() << ", " << as.str() << ": saved" << std::endl;
            imageNum++;
        }

        cv::rectangle(color, cv::Point(5, 5), cv::Point(635, 475),
                      cv::Scalar(255, 0, 0), 3);
    } else {
        cv::rectangle(color, cv::Point(5, 5), cv::Point(635, 475),
                      cv::Scalar(0, 0, 255), 3);
    }

    cv::imshow("color", color);
    cv::imshow("depth", scaled);

    if (cv::waitKey(1) == 'q')
        std::exit(0);
}
示例#26
0
void Skin::DrawVerticalEdgedRectElement(const EdgedRectElement &element, const Point &pos, const Point &size) const
{
	const float height = element.edgeWidth;

	Graphics::VertexArray va(Graphics::ATTRIB_POSITION | Graphics::ATTRIB_UV0);

	va.Add(vector3f(pos.x+size.x, pos.y,               0.0f), scaled(vector2f(element.pos.x+element.size.x, element.pos.y)));
	va.Add(vector3f(pos.x,        pos.y,               0.0f), scaled(vector2f(element.pos.x,                element.pos.y)));
	va.Add(vector3f(pos.x+size.x, pos.y+height,        0.0f), scaled(vector2f(element.pos.x+element.size.x, element.pos.y+height)));
	va.Add(vector3f(pos.x,        pos.y+height,        0.0f), scaled(vector2f(element.pos.x,                element.pos.y+height)));
	va.Add(vector3f(pos.x+size.x, pos.y+size.y-height, 0.0f), scaled(vector2f(element.pos.x+element.size.x, element.pos.y+element.size.y-height)));
	va.Add(vector3f(pos.x,        pos.y+size.y-height, 0.0f), scaled(vector2f(element.pos.x,                element.pos.y+element.size.y-height)));
	va.Add(vector3f(pos.x+size.x, pos.y+size.y,        0.0f), scaled(vector2f(element.pos.x+element.size.x, element.pos.y+element.size.y)));
	va.Add(vector3f(pos.x,        pos.y+size.y,        0.0f), scaled(vector2f(element.pos.x,                element.pos.y+element.size.y)));

	m_renderer->DrawTriangles(&va, m_material.Get(), Graphics::TRIANGLE_STRIP);
}
示例#27
0
 virtual void drawTransform(const btTransform& transform, btScalar orthoLen)
 {
   btVector3 origin = transform.getOrigin() / bulletWorldScalingFactor;
   btQuaternion rotation = transform.getRotation();
   double transform_[7] = {origin.x(), origin.y(), origin.z(),
                           rotation.x(), rotation.y(), rotation.z(),
                           rotation.w()};
   
   if(callbacks_.drawTransform)
     (*callbacks_.drawTransform)(transform_, orthoLen / bulletWorldScalingFactor, arg_);
   else
   {
     btTransform scaled(rotation, origin);
     btIDebugDraw::drawTransform(scaled, orthoLen / bulletWorldScalingFactor);
   }
 }
示例#28
0
void Skin::DrawHorizontalEdgedRectElement(const EdgedRectElement &element, const Point &pos, const Point &size) const
{
	const float width = element.edgeWidth;

	Graphics::VertexArray va(Graphics::ATTRIB_POSITION | Graphics::ATTRIB_UV0);

	va.Add(vector3f(pos.x,              pos.y,        0.0f), scaled(vector2f(element.pos.x,                      element.pos.y)));
	va.Add(vector3f(pos.x,              pos.y+size.y, 0.0f), scaled(vector2f(element.pos.x,                      element.pos.y+element.size.y)));
	va.Add(vector3f(pos.x+width,        pos.y,        0.0f), scaled(vector2f(element.pos.x+width,                element.pos.y)));
	va.Add(vector3f(pos.x+width,        pos.y+size.y, 0.0f), scaled(vector2f(element.pos.x+width,                element.pos.y+element.size.y)));
	va.Add(vector3f(pos.x+size.x-width, pos.y,        0.0f), scaled(vector2f(element.pos.x+element.size.x-width, element.pos.y)));
	va.Add(vector3f(pos.x+size.x-width, pos.y+size.y, 0.0f), scaled(vector2f(element.pos.x+element.size.x-width, element.pos.y+element.size.y)));
	va.Add(vector3f(pos.x+size.x,       pos.y,        0.0f), scaled(vector2f(element.pos.x+element.size.x,       element.pos.y)));
	va.Add(vector3f(pos.x+size.x,       pos.y+size.y, 0.0f), scaled(vector2f(element.pos.x+element.size.x,       element.pos.y+element.size.y)));

	m_renderer->SetBlendMode(Graphics::BLEND_ALPHA);
	m_renderer->DrawTriangles(&va, m_material.Get(), Graphics::TRIANGLE_STRIP);
}
示例#29
0
文件: main.c 项目: conghui/books
static void draw_horizontal_histogram(const int *word_len, int size)
{
    int i;
    int num_tag;
    int max;

    max = max_value(word_len, size);

    printf("%10s %2s %5s\n", "word_len", "-", "count");
    for (i = 1; i < size; i++) {
        printf("%6d %6s %3d: ", i, "-", word_len[i]);
        num_tag = scaled(word_len[i], max);
        draw_tag(num_tag);
        putchar('\n');
    }

}
void DS325CalibWorker::calibrateDepth(cv::Mat& source, cv::Mat& result) {
    const uint MAX_DEPTH = 1000;
    const uint MIN_DEPTH = 0;

    // I'm not sure why this is neccesary.
    cv::Mat maxDist = cv::Mat::ones(_csize, CV_16U) * MAX_DEPTH;
    cv::Mat minDist = cv::Mat::ones(_csize, CV_16U) * MIN_DEPTH;
    cv::Mat scaled;
    cv::resize(source, scaled, _csize);
    cv::min(scaled, maxDist, scaled);
    scaled -= minDist;

    cv::Mat cropped = scaled(cv::Rect(40, 43, 498, 498 / 4 * 3)); // TODO
    cv::resize(cropped, cropped, _csize);
    cv::Mat temp;
    cv::remap(cropped, temp, _rectifyMaps[1][0], _rectifyMaps[1][1], CV_INTER_LINEAR);
    cv::resize(temp(validROI[1]), result, _dsize);
}