Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » StreamRasterEncoder puzzle
StreamRasterEncoder puzzle [message #15282] Tue, 15 April 2008 15:07 Go to previous message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
So here's a puzzle for you:

The following piece of code writes all four image types but the resulting PNG and TIF files cannot be read by photoshop elements. They can be read by other less fussy types of image viewer. And here's the bit that's puzzling, when I use the same plugins elsewhere to write TIF and PNG, photoshop reads the resulting files just fine and even with this code, photoshop can read the resulting BMP and JPG files just fine. Can you find the error?


bool RasterLayer::SaveLegendAsImage(String path)
{
	StreamRasterEncoder* pEnc=NULL;
	
	if(path.Find(".jpg") || path.Find(".JPG"))
	{
		pEnc = new JPGEncoder(100);	// top quality		
	}
	else if(path.Find(".png") || path.Find(".PNG"))
	{
		pEnc = new PNGEncoder();	// default 32bpp		
	}
	else if(path.Find(".tif") || path.Find(".TIF"))
	{
		pEnc = new TIFEncoder(); 	// default 24bpp		
	}
	else if(path.Find(".bmp") || path.Find(".BMP"))
	{
		pEnc = new BMPEncoder();	// default 24bpp		
	}
	else
	{
		return false;
	}
	
	ImageDraw id(2000,2000);
	DrawLegend(id);
	
	Image img = id.GetStraight();
	
	pEnc->SaveFile(path,img);
	
	delete pEnc;
	
	return true;
}


Cheers,

Nick

EDIT: the following code (and you can see the different things I've tried commented out) has the same effect

bool RasterLayer::SaveLegendAsImage(String& path)
{
	ImageDraw id(1500,2000);
	DrawLegend(id);
	
//	Image img = id.GetStraight();
//	Image img(id);

	ImageBuffer ib(id);
	Image img(ib);
	
	if(path.Find(".jpg") || path.Find(".JPG"))
	{
		JPGEncoder enc(100);	// top quality	
		if(!enc.SaveFile(path,img))
		{
			PromptOK("problem saving legend");
			return false;	
		}
	}
	else if(path.Find(".png") || path.Find(".PNG"))
	{
		PNGEncoder enc;	// default 32bpp		
		if(!enc.SaveFile(path,img))
		{
			PromptOK("problem saving legend");
			return false;	
		}
	}
	else if(path.Find(".tif") || path.Find(".TIF"))
	{
		TIFEncoder enc; 	// default 24bpp		
		if(!enc.SaveFile(path,img))
		{
			PromptOK("problem saving legend");
			return false;	
		}
	}
	else if(path.Find(".bmp") || path.Find(".BMP"))
	{
		BMPEncoder enc;	// default 24bpp		
		if(!enc.SaveFile(path,img))
		{
			PromptOK("problem saving legend");
			return false;	
		}
	}
	else
	{
		return false;
	}
	
	return true;
}

[Updated on: Tue, 15 April 2008 17:39]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: CtrlPaint Bug: Frame draws outside of Ctrl
Next Topic: theIDE: Passing cmd line argument during DEBUG?
Goto Forum:
  


Current Time: Sat Apr 27 17:27:55 CEST 2024

Total time taken to generate the page: 2.02760 seconds