try { if ( qimg.Width > 258 ) { prev_width = qimg.Width / ( qimg.Width / 258 ); prev_height = qimg.Height / ( qimg.Width / 258 ); } else if ( qimg.Height > 225 ) { prev_width = qimg.Width / ( qimg.Height / 225 ); prev_height = qimg.Height / ( qimg.Height / 225 ); } else if ( qimg.Width < 258 && qimg.Height < 225 ) { prev_width = qimg.Width; prev_height = qimg.Height; } }