Ejemplo n.º 1
0
void GraphicEngine::drawSplitImage(const std::string & name, const Transformation & t, const Color & color)
{
	if (cachedImages.find(name) == cachedImages.end() &&
		!loadImageFromFile(name)) {
		DEBUG_MSG("Couldn't open texture file: \"" << name << "\"");
		return;
	}

	sf::IntRect subRect;
	if (t.hasCrop())
	{
		subRect.left = t.getCrop().at(Transformation::CROP::SRCX);
		subRect.top = t.getCrop().at(Transformation::CROP::SRCY);
		subRect.width = t.getCrop().at(Transformation::CROP::SRCWIDTH);
		subRect.height = t.getCrop().at(Transformation::CROP::SRCHEIGHT);
	}
	else
	{
		subRect.left = 0;
		subRect.top = 0;
		subRect.width = cachedImages[name]->getSize().x;
		subRect.height = cachedImages[name]->getSize().x;
	}

	sf::Sprite sprite(*cachedImages[name], subRect);
	transformSprite(sprite, t, color);
	window->draw(sprite);
}
Ejemplo n.º 2
0
const sf::Texture& GraphicEngine::loadTexture(const std::string& img)
{
	if (cachedImages.find(img) == cachedImages.end() &&
		!loadImageFromFile(img)) {
		DEBUG_MSG("Couldn't open texture file: \"" << img << "\"");
		return *None;
	}
	return *cachedImages[img];
}
Ejemplo n.º 3
0
void GraphicEngine::drawImage(const std::string& name, const Transformation& t, const Color& color)
{
	if (cachedImages.find(name) == cachedImages.end() &&
		!loadImageFromFile(name)) {
		DEBUG_MSG("Couldn't open texture file: \"" << name << "\"");
		return;
	}
	sf::Sprite sprite(*cachedImages[name]);
	transformSprite(sprite, t, color);
	window->draw(sprite);
}
Ejemplo n.º 4
0
PassRefPtr<Image> Image::loadPlatformResource(const char* name)
{
    CString fileName;
    if (!strcmp("missingImage", name))
        fileName = getThemeIconFileName(GTK_STOCK_MISSING_IMAGE, 16);
    if (fileName.isNull()) {
        GUniquePtr<gchar> imageName(g_strdup_printf("%s.png", name));
        GUniquePtr<gchar> glibFileName(getPathToImageResource(imageName.get()));
        fileName = glibFileName.get();
    }

    return loadImageFromFile(fileName);
}
Ejemplo n.º 5
0
void EmotHandler::fillLV(iLV* _lv) {
  EmotLV* lv = (EmotLV*) _lv;
  oImage img;

  for (tPackages::iterator it = _packages.begin(); it != _packages.end(); it++) {
    eMSet* set = (eMSet*) *it;
    if (!set->getEmots().size()) {
      continue;
    }
    img = loadImageFromFile(set->getEmots()[0].getMenuImgPath().c_str());
    lv->addItem(new EmotLV::sEmotPackInfo(set->isEnabled(), &*set, img));
  }
}
Ejemplo n.º 6
0
PassRefPtr<Image> Image::loadPlatformResource(const char* name)
{
    CString fileName;
    if (!strcmp("missingImage", name))
        fileName = getThemeIconFileName(GTK_STOCK_MISSING_IMAGE, 16);
    if (fileName.isNull()) {
        GOwnPtr<gchar> imageName(g_strdup_printf("%s.png", name));
        GOwnPtr<gchar> glibFileName(g_build_filename(getWebKitDataDirectory(), "webkitgtk-"WEBKITGTK_API_VERSION_STRING, "images", imageName.get(), NULL));
        fileName = glibFileName.get();
    }

    return loadImageFromFile(fileName);
}
Ejemplo n.º 7
0
PassRefPtr<Image> Image::loadPlatformResource(const char* name)
{
    CString fileName;
    if (!strcmp("missingImage", name))
        fileName = getThemeIconFileName(GTK_STOCK_MISSING_IMAGE, 16);
    if (fileName.isNull()) {
        gchar* imagename = g_strdup_printf("%s.png", name);
        gchar* glibFileName = g_build_filename(DATA_DIR, "webkit-1.0", "images", imagename, 0);
        fileName = glibFileName;
        g_free(imagename);
        g_free(glibFileName);
    }

    return loadImageFromFile(fileName);
}
Ejemplo n.º 8
0
void getTexture(char *imageFileName, Image *image, GLint texImageName)
{
  image = (Image *) malloc(sizeof(Image));
  // allocate space for texture
  if (image == NULL) {
    printf("Error allocating space for image");
    exit(0);
  }

  if (!loadImageFromFile(imageFileName, image)) exit(1);
  glBindTexture(GL_TEXTURE_2D, texImageName);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // scale linearly when image bigger than texture
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // scale linearly when image smalled than texture
  glTexImage2D(GL_TEXTURE_2D, 0, 3, image->sizeX, image->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, image->data);
}
//Laddar in bilder i en std::map
sf::Image* ResourceHandler::loadImage(const std::string &path)
{
	//skapar en imagepekare och tilldelar denna bilden som hör till strängen som laddats in
	sf::Image* image = Images[path]; 

	/*
	 * Om sf::Image pekaren har värdet noll tilldelas dennna informationen från funktionen
	 * loadImageFromFile och ger informationenen vidare i mappen med en tillhörande sträng 
	 */
	if(image == NULL) 
	{
		image = loadImageFromFile(path);
		Images[path] = image;
	}
	return image;
}
Ejemplo n.º 10
0
void generate_stl(const char *filenames_format_string, int min_n, int max_n,int step_n, int dimensions[], const char * stl_filename)
{
	vtkSmartPointer<vtkImageData> im=allocateImage(dimensions);

	for(int co=min_n; co<=max_n; co+=step_n)
	{
		for(char ch = 'E'; ch <= 'H'; ch++)
		{
			char buff[1024];
			sprintf(buff, filenames_format_string ,co,ch);
			loadImageFromFile(buff,im,dimensions);
		}
	}

	vtkSmartPointer<vtkPolyDataMapper> mapper;
	vtkSmartPointer<vtkLODActor> actor;
	vtkSmartPointer<vtkMarchingCubes> contourf = vtkSmartPointer<vtkMarchingCubes>::New();
	contourf->SetInputData(im);
	contourf->SetValue(0,127);
	contourf->ComputeNormalsOff();
	contourf->ComputeScalarsOff();
	contourf->ComputeGradientsOff();
//	contourf->SetInputMemoryLimit(500000);
	printf("About to update contourf");
	contourf->Update();
	printf("Contour Generated");
	vtkSmartPointer<vtkSmoothPolyDataFilter> smoothf = vtkSmartPointer<vtkSmoothPolyDataFilter>::New();
	smoothf->SetInputData(contourf->GetOutput());
	smoothf->SetRelaxationFactor(0.1);
	smoothf->SetNumberOfIterations(20);
	smoothf->Update();
	printf("Contour smoothed\n");
    mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
	mapper->SetInputData(smoothf->GetOutput());
	printf("Begin updating mapper\n");
	mapper->Update();
	vtkSmartPointer<vtkPLYWriter> stlwriter = vtkSmartPointer<vtkPLYWriter>::New();
	stlwriter->SetInputData(smoothf->GetOutput());
	stlwriter->SetFileName(stl_filename);
	stlwriter->SetFileTypeToBinary();
	printf("Begin Writing stl file %s\n", stl_filename);
	stlwriter->Write();
	printf("Done writing to stl file");
	//im->Delete();
}
Ejemplo n.º 11
0
PassRefPtr<Image> Image::loadPlatformThemeIcon(const char* name, int size)
{
    return loadImageFromFile(getThemeIconFileName(name, size));
}
Ejemplo n.º 12
0
static void refreshPatch()
{
	SendDlgItemMessage(hIpsDlg, IDC_TEXTCOMMENT, WM_SETTEXT, 0, 0);

	HTREEITEM hSelectHandle = TreeView_GetNextItem(hIpsList, ~0U, TVGN_CARET);
	if (!hSelectHandle) {
		return;
	}

	if (hPreview) {
		DeleteObject((HGDIOBJ)hPreview);
		hPreview = NULL;
	}

	for (int i = 0; i < nNumPatches; i++) {
		if (hSelectHandle == hPatchHandlesIndex[i]) {
			FILE* fp = _tfopen(szPatchFileNames[i], _T("r"));
			if (fp) {
				TCHAR* PatchDesc = getPatchDescByLangcode(fp, nPatchLang);
				// If not available - try English first
				if (PatchDesc == NULL) {
					PatchDesc = getPatchDescByLangcode(fp, 0);
					// Simplified Chinese is the reference language
					if (PatchDesc == NULL) {
						PatchDesc = getPatchDescByLangcode(fp, 1);
					}
				}
				if (PatchDesc == NULL) {
					fclose(fp);
					break;
				}

				SendDlgItemMessage(hIpsDlg, IDC_TEXTCOMMENT, WM_SETTEXT, 0, (LPARAM)PatchDesc);
				fclose(fp);
			}

			// set preview image filename
			TCHAR szPatchDatName[MAX_PATH] = _T("");
			TCHAR szImageFileName[MAX_PATH] = _T("");

			TCHAR* szGameName = BurnDrvGetText(DRV_NAME);
			getPatchFilename(szGameName, szPatchDatName, i);
			getPatchPrevName(szImageFileName, szGameName, szPatchDatName);
			_tcscat(szImageFileName, _T(".png"));

			// load image
			HBITMAP hNewImage = loadImageFromFile(szImageFileName, hIpsDlg, nLoadMenuShowX & KEEPGAMEASPECT);
			if (hNewImage) {
				hPreview = hNewImage;
				SendDlgItemMessage(hIpsDlg, IDC_SCREENSHOT_H, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hPreview);
				movePatchPreviewPos();
			} else {
				SendDlgItemMessage(hIpsDlg, IDC_SCREENSHOT_H, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hDefPreview);
				resetPatchPreviewPos();
			}

			return;
		}
	}

	SendDlgItemMessage(hIpsDlg, IDC_SCREENSHOT_H, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hDefPreview);
	resetPatchPreviewPos();
}