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 next 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 );
}
Re: I propose to include function PropRescale. [message #24044 is a reply to message #24043] Tue, 22 December 2009 15:57 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Sergey

I think your proposal is similar to this in Functions4U:

template <class T>
Rect_<T> FitInFrame(const Size_<T> &frame, const Size_<T> &object)
{
	double frameAspect  = frame.cx/(double)frame.cy; 
	double objectAspect = object.cx/(double)object.cy;	
	
	if (frameAspect > objectAspect) {
		double x = (frame.cx - objectAspect*frame.cy)/2.;
		return Rect_<T>((T)x, 0, (T)(x + objectAspect*frame.cy), frame.cy);
	} else {
		double y = (frame.cy - frame.cx/objectAspect)/2.;
		return Rect_<T>(0, (T)y, frame.cx, (T)(y + frame.cx/objectAspect));
	}
}


From Functions4U documentation:

index.php?t=getfile&id=2055&private=0

Best regards
Koldo
  • Attachment: Screen.PNG
    (Size: 142.43KB, Downloaded 660 times)


Best regards
Iñaki
Re: I propose to include function PropRescale. [message #24045 is a reply to message #24044] Tue, 22 December 2009 18:49 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

Could you give an example of use this template?

I still think that the task to display the picture in any Control, and while it fit in the Control are standard, and would be better off just when you display a control would have been just any flag.

Finally, I have these functions in a separate package. But the task of manipulating the images so often and that you want to include the output function as standard. I just tried to make calls to these functions as possible similar to the original functions.

By the way, I think that is proportional to output images is used much more often than not proportional, and should at least include it in the base system. Better yet, make a proportional output images - by default.


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: I propose to include function PropRescale. [message #24046 is a reply to message #24045] Tue, 22 December 2009 21:33 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Sergey

Quote:

Could you give an example of use this template?


If MyImage contains an image member:

void MyImage::Paint(Draw& w) {
	w.DrawImage(FitInFrame(GetSize(), image->GetSize()), image);
}


Best regards
Koldo


Best regards
Iñaki
Re: I propose to include function PropRescale. [message #24047 is a reply to message #24046] Tue, 22 December 2009 21:36 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

Yes, decision looks beautifully.

SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: I propose to include function PropRescale. [message #24048 is a reply to message #24047] Tue, 22 December 2009 21:40 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

Do I need for these actions to create a class?

SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: I propose to include function PropRescale. [message #24049 is a reply to message #24048] Tue, 22 December 2009 22:09 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Sergey

This sample has been extracted from StaticImage class in Controls4U.

As I did not find in documentation a control to view an image I created one. After that I discover a control for that.

In this class what I called "BestFit" option is default as I also think that this is the more useful one. In addition to that this class permit:
- to include a background image for the window
- to enclose the control in the layout designer

I think that these are simple to implement lightweight options to be included in a basic image control. If it is possible to include them in any way in the official image control I would be glad to remove StaticImage control.

Best regards
Koldo



Best regards
Iñaki
Re: I propose to include function PropRescale. [message #24060 is a reply to message #24049] Wed, 23 December 2009 18:44 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
Hello Koldo,

what is the official StaticImage control ??

Re: I propose to include function PropRescale. [message #24064 is a reply to message #24060] Wed, 23 December 2009 21:11 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Didier wrote on Wed, 23 December 2009 18:44

Hello Koldo,

what is the official StaticImage control ??




Hello Didier

Oh no!. StaticImage is in Controls4U Bazaar package so it is not official at all Smile.

If you want to try it run the Controls4U_Demo package.

Best regards
Koldo


Best regards
Iñaki

[Updated on: Wed, 23 December 2009 21:11]

Report message to a moderator

Re: I propose to include function PropRescale. [message #24066 is a reply to message #24064] Wed, 23 December 2009 23:52 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
Oups ... Embarassed

I misunderstood when you said:
Quote:

.... view an image I created one. After that I discover a control for that



And I had already tested the Controls4U_Demo package (works fine Cool ) and the StaticImage ctrl is VERY welcome : it's kind of a basic ctrl but a VERY important one.

Thanks
Re: I propose to include function PropRescale. [message #24072 is a reply to message #24066] Thu, 24 December 2009 11:06 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
BTW, since the dawn of U++, there is GetFitSize function and Rect::CenterPos method.... Wink

Mirek
Re: I propose to include function PropRescale. [message #24075 is a reply to message #24072] Thu, 24 December 2009 16:55 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
luzr wrote on Thu, 24 December 2009 11:06

BTW, since the dawn of U++, there is GetFitSize function and Rect::CenterPos method.... Wink

Mirek


Hello Mirek

I think it is really important to document all the functions and classes that are lost around the code. Many times we are reinventing the wheel spending time in it.

In addition it would be fundamental to have all the documentation linked and in one file (pdf). Unfortunately it is easier to find documentation this way instead of using our help system or browsing the web.

Best regards
Koldo


Best regards
Iñaki
Re: I propose to include function PropRescale. [message #24078 is a reply to message #24072] Thu, 24 December 2009 19:32 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

Hello Mirek.

Thank you for GetFitSize. GetFitSize - this is what I need.

Pity there is no Help topic on Image Processing.

Say pls. where the module (or, where .h file), where I can see all this wealth?


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}

[Updated on: Thu, 24 December 2009 21:40]

Report message to a moderator

Re: I propose to include function PropRescale. [message #24084 is a reply to message #24075] Fri, 25 December 2009 11:54 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Thu, 24 December 2009 10:55

luzr wrote on Thu, 24 December 2009 11:06

BTW, since the dawn of U++, there is GetFitSize function and Rect::CenterPos method.... Wink

Mirek


Hello Mirek

I think it is really important to document all the functions and classes that are lost around the code. Many times we are reinventing the wheel spending time in it.

In addition it would be fundamental to have all the documentation linked and in one file (pdf). Unfortunately it is easier to find documentation this way instead of using our help system or browsing the web.

Best regards
Koldo



I keep trying...

That said, the process is completely open. Everybody with access to primary svn can submit documentation. Almost everybody has access to uppbox and can submit changes to website. There is no fundamental problem converting documentation to pdf, except perhaps the fact that you will need to generate or write some Content summary.

Mirek
Re: I propose to include function PropRescale. [message #24085 is a reply to message #24078] Fri, 25 December 2009 11:55 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
sergeynikitin wrote on Thu, 24 December 2009 13:32

Hello Mirek.

Thank you for GetFitSize. GetFitSize - this is what I need.

Pity there is no Help topic on Image Processing.

Say pls. where the module (or, where .h file), where I can see all this wealth?


Actually, they are not really Image specific - these are Rect/Size functions. That is why they are in Core/GTypes.h

Mirek
Previous Topic: IMAGECLASS::Iml() crashes
Next Topic: Variable pitch fonts
Goto Forum:
  


Current Time: Fri Mar 29 14:40:45 CET 2024

Total time taken to generate the page: 0.01496 seconds