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 » I propose to include function PropRescale.
I propose to include function PropRescale. [message #24043] Tue, 22 December 2009 15:06 Go to previous message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

I propose to include in the base package in addition to the functions Rescale function propRescale.

commonfucnc.h:
Image PropRescale(const Image& im, const Size res_size);
Image PropRescale(const Image& im, const int cx, const int cy);
Image PropRescale(const Image& im, const ImageCtrl& imc);
void PropRescale(const Image& im, ImageCtrl& imc ,const bool setimage);


commonfunc.cpp:
Image PropRescale(const Image& im, const Size res_size){
	Size imsize,ressize=res_size;
	imsize = im.GetSize();
	if (imsize.cx > 0 && imsize.cy > 0) {
		double ixy = double(imsize.cx)/imsize.cy;
		double rxy = double(ressize.cx)/ressize.cy;
		if (rxy>ixy) {
			ressize.cx = ressize.cy*imsize.cx/imsize.cy;
		} else {
			ressize.cy = ressize.cx*imsize.cy/imsize.cx;
		}
		return Rescale(im,ressize);
	}
}

Image PropRescale(const Image& im,const int cx,const int cy) {
	Size ressize;
	ressize.cx = cx;
	ressize.cy = cy;
	return PropRescale(im,ressize);
}

Image PropRescale(const Image& im, const ImageCtrl& imc) {
	Image i = PropRescale(im,imc.GetSize());
	return i;
}

void PropRescale(const Image& im, ImageCtrl& imc ,const bool setimage) {
	Image i = PropRescale(im,imc.GetSize());
	if (setimage) imc.SetImage(i);
	return;
}


I use it to display images in ImageCtrl, therefore, as a parameter to some of the call option is ImageCtrl.

The function uses real arithmetic. I was going to transfer all of integer arithmetic, but so far not done so.

Another point. I do not quite understand CacheRescale, so long and did not interface to CacheRescale.

PS.
Perhaps there is a solution makes it unnecessary to my exercises. If so, could you tell. And then I may be wrong, to reinvent the wheel?


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
 
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: IMAGECLASS::Iml() crashes
Next Topic: Variable pitch fonts
Goto Forum:
  


Current Time: Sat Apr 27 00:02:20 CEST 2024

Total time taken to generate the page: 0.04635 seconds