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 » Draw, Display, Images, Bitmaps, Icons » How to set the dpi (dots per inch) of an image
Re: How to set the dpi (dots per inch) of an image [message #28731 is a reply to message #28725] Tue, 14 September 2010 09:51 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Mirek

It is done. Here a sample code using GetDPI() and SetDPI():

include <Core/Core.h>
#include <plugin/png/png.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	Image img = StreamRaster::LoadFileAny(AppendFileName(GetDesktopFolder(), "demo.png"));
	if (!img) 
		puts("No image");
	else {
		ImageBuffer image(img);
		
		Size dpi = image.GetDPI();
		puts(Format("Image DPI are %d/%d", dpi.cx, dpi.cy));
		image.SetDPI(Size(600, 600));
		puts("New DPI values will be 600/600");
		
		PNGEncoder png;
		png.SaveFile(AppendFileName(GetDesktopFolder(), "demo2.png"), image);	
		puts("Done");
	}
	getchar();
}


The DPI is only effectively set in "PNG" format files.

I will include the changed files today. They are a few.


Best regards
IƱaki
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Icon at right side of the menuBar
Next Topic: GetExifThumbnail doc
Goto Forum:
  


Current Time: Tue Apr 16 19:44:36 CEST 2024

Total time taken to generate the page: 0.01654 seconds