コード例 #1
0
ファイル: AEGLRenderBG.cpp プロジェクト: klokik/AEngine
	void AEGLRenderUnit::RenderEmpties(void)
	{
		for(size_t q=0;q<type_cache.empties.size();q++)
		{
			RenderEmpty(type_cache.empties[q]);
		}
	}
コード例 #2
0
CDIB* CRenderThread::Render(GP<DjVuImage> pImage, const CSize& size,
		const CDisplaySettings& displaySettings, int nDisplayMode,
		int nRotate, bool bThumbnail)
{
	if (size.cx <= 0 || size.cy <= 0)
		return NULL;

	CSize szImage(pImage->get_width(), pImage->get_height());
	int nTotalRotate = GetTotalRotate(pImage, nRotate);

	CSize szScaled(size);
	if (nTotalRotate % 2 != 0)
		swap(szScaled.cx, szScaled.cy);

	GRect rect(0, 0, szScaled.cx, szScaled.cy);

	bool bScalePnmFixed = displaySettings.bScaleColorPnm;

	// Use fast scaling for thumbnails.
	if (bThumbnail)
		bScalePnmFixed = false;

	// Use default faster scaling when zoom factor is >= 1.0.
	// Additionally, use the default scaling when requested
	// image size is small, since quality does not matter at this
	// scale. NOTE: this also deals with the special case of size (1, 1),
	// which can force PnmScaleFixed into an infinite loop.
	if ((szScaled.cx < 150 || szScaled.cy < 150)
			|| (szScaled.cx >= szImage.cx || szScaled.cy >= szImage.cy))
		bScalePnmFixed = false;

	// Disable PnmFixed scaling if we perform an integer reduction of the image.
	/*
	for (int nReduction = 1; nReduction <= 15; ++nReduction)
	{
		if (szScaled.cx*nReduction > szImage.cx - nReduction
				&& szScaled.cx*nReduction < szImage.cx + nReduction
				&& szScaled.cy*nReduction > szImage.cy - nReduction
				&& szScaled.cy*nReduction < szImage.cy + nReduction)
		{
			bScalePnmFixed = false;
			break;
		}
	}
	*/

	// Disable PnmFixed scaling for color images according to settings
	GP<IW44Image> bg44 = pImage->get_bg44();
	GP<GPixmap> bgpm = pImage->get_bgpm();
	GP<GPixmap> fgpm = pImage->get_fgpm();
	if (!displaySettings.bScaleColorPnm && (bg44 != NULL || bgpm != NULL || fgpm != NULL)
			&& nDisplayMode != CDjVuView::BlackAndWhite)
		bScalePnmFixed = false;

	if (bScalePnmFixed)
		rect = GRect(0, 0, szImage.cx, szImage.cy);

	GP<GBitmap> pGBitmap;
	GP<GPixmap> pGPixmap;

	try
	{
		switch (nDisplayMode)
		{
		case CDjVuView::BlackAndWhite:
			pGBitmap = pImage->get_bitmap(rect, rect, 4);
			break;

		case CDjVuView::Foreground:
			pGPixmap = pImage->get_fg_pixmap(rect, rect);
			if (pGPixmap == NULL)
				pGBitmap = pImage->get_bitmap(rect, rect, 4);
			break;

		case CDjVuView::Background:
			pGPixmap = pImage->get_bg_pixmap(rect, rect);
			break;

		case CDjVuView::Color:
		default:
			pGPixmap = pImage->get_pixmap(rect, rect);
			if (pGPixmap == NULL)
				pGBitmap = pImage->get_bitmap(rect, rect, 4);
		}
	}
	catch (GException&)
	{
		return NULL;
	}
	catch (CMemoryException*)
	{
		return NULL;
	}
	catch (...)
	{
		theApp.ReportFatalError();
	}

	CDIB* pBitmap = NULL;

	if (pGPixmap != NULL)
	{
		if (nTotalRotate != 0)
			pGPixmap = pGPixmap->rotate(nTotalRotate);

		if (bScalePnmFixed)
			pGPixmap = RescalePixmap_subpix(pGPixmap, size.cx, size.cy);

		pBitmap = RenderPixmap(*pGPixmap, displaySettings);
	}
	else if (pGBitmap != NULL)
	{
		if (nTotalRotate != 0)
			pGBitmap = pGBitmap->rotate(nTotalRotate);

		if (bScalePnmFixed)
		{
			pGPixmap = RescaleBitmap_subpix(pGBitmap, size.cx, size.cy);
			pBitmap = RenderPixmap(*pGPixmap, displaySettings);
		}
		else
		{
			pBitmap = RenderBitmap(*pGBitmap, displaySettings);
		}
	}
	else
	{
		pBitmap = RenderEmpty(size, displaySettings);
	}

	if (pBitmap != NULL)
		pBitmap->SetDPI(pImage->get_dpi());

	return pBitmap;
}