NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 70 71 72 73 74 … 93 Next »
who is good at maths?

 
  • 0 Vote(s) - 0 Average
who is good at maths?
Heyt
Offline

Member

Posts: 106
Threads: 9
Joined: Jan 2005
#31
2005-07-07, 09:41 PM
just tested zooming out and it will also work if with a slightly change in the code

Code:
double leftpos = current.X; //only first time when zoom is 1
double toppos = current.Y; //only first time when zoom is 1


double leftoff = (-1 * current.X) - leftpos;
double topoff = (-1 * current.Y) - toppos;

double oldWidth = current.Width;
double oldHeight = current.Height;

current.Width = current.OriginalWidth * current.Zoom;
current.Height = current.OriginalHeight * current.Zoom;

if (oldWidth <= ScreenWidth)
{
current.X -= ((current.Width - oldWidth) / 2);
}
else
{
current.X = (-1 * leftoff * current.Zoom / oldZoom) - (((ScreenWidth * current.Zoom / oldZoom) - ScreenWidth) / 2);
  if (current.X > 0)
  {
  current.X = current.X * -1;
  }
  else
  {
  current.X -= leftpos;
  }
}

if (oldHeight <= ScreenHeight)
{
current.Y -= ((current.Height - oldHeight) / 2);
}
else
{
current.Y = (-1 * topoff * current.Zoom / oldZoom) - (((ScreenHeight * current.Zoom / oldZoom) - ScreenHeight) / 2);
  if (current.Y > 0)
  {
  current.Y = current.Y * -1;
  }
  else
  {
  current.Y -= toppos;
  }
}
smeghead
Offline

Senior Member

Posts: 300
Threads: 23
Joined: Jan 2005
#32
2005-07-07, 09:56 PM
I've done some testing and attached the whole project directory as a zip.

I had to comment out the re-centering code as I couldn't get it quite right. I also need to test the ratio settins with a more obscure image rectangle.

You will need to put a jpeg file as C:\temp\test.jpg but you can alter this in the code.

The executable should be in there as well

I'll keep testing with a more rectangular rectangle to make sure it works properly. When zoom is 1.0 then the image is shown as best fit in the screen. When Zoom is more than 1.0 then the whole screen area is used.
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#33
2005-07-07, 10:33 PM
hey smeghead whats the deal with the "@" here
c = new Class1(@"c:\temp\test.jpg");
ive seen it here and there, and have no idea what it does (if anything).
smeghead
Offline

Senior Member

Posts: 300
Threads: 23
Joined: Jan 2005
#34
2005-07-07, 10:43 PM
It makes sure that the string is treated like a directory path and makes any changes necessary i.e. the \ parameter isn't taken as an escape sequence but as a directory seperator.
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#35
2005-07-07, 10:45 PM
oh, is there a way to reverse it? to escape all those characters? ie to prevent code injection (we covered this in uni, but only for php).
smeghead
Offline

Senior Member

Posts: 300
Threads: 23
Joined: Jan 2005
#36
2005-07-07, 10:52 PM
Done another version that corrects the aspect ratio when zooming.

I'm probably about to stop doing this now if that's OK. The code to centre the image doesn't work (and is currently commented out) but i'm not convinced that it's needed anyway - let me know if you think it is and i'll have another go.
smeghead
Offline

Senior Member

Posts: 300
Threads: 23
Joined: Jan 2005
#37
2005-07-07, 10:53 PM
reven Wrote:oh, is there a way to reverse it? to escape all those characters? ie to prevent code injection (we covered this in uni, but only for php).

Can't remember - sorry
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#38
2005-07-07, 11:18 PM
smeghead Wrote:Can't remember - sorry
thats cool, just curious.

thanks for the help, i should be able to put it all together now.
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#39
2005-07-07, 11:42 PM
sweet! its working! im so happy, thanks guys for all your help. all i go to do now is do some safety checks on moving/zooming out but thats no biggy.

really thank you guys, this one had me stumped.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (4): « Previous 1 2 3 4


Possibly Related Threads…
Thread Author Replies Views Last Post
  What's a good Open Source VB.net plugin that I could browse? zehd 0 1,173 2007-01-30, 02:00 AM
Last Post: zehd
  Anyone recommend a good C# book? bgowland 9 3,570 2005-01-03, 07:32 PM
Last Post: bgowland

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode