@@ -81,38 +81,38 @@ public void ProcessRequest(HttpContext context)
81
81
var viewPortH = float . Parse ( context . Request [ "viewPortH" ] ) ;
82
82
var viewPortW = float . Parse ( context . Request [ "viewPortW" ] ) ;
83
83
84
- bool bSaveFile ;
84
+ bool saveFile ;
85
85
86
86
try
87
87
{
88
- bSaveFile = bool . Parse ( context . Request [ "saveFile" ] ) ;
88
+ saveFile = bool . Parse ( context . Request [ "saveFile" ] ) ;
89
89
}
90
90
catch ( Exception )
91
91
{
92
- bSaveFile = false ;
92
+ saveFile = false ;
93
93
}
94
94
95
- string sNewFileName = null ;
95
+ string newFileName = null ;
96
96
97
97
if ( ! string . IsNullOrEmpty ( context . Request [ "newFileName" ] ) )
98
98
{
99
- sNewFileName = context . Request [ "newFileName" ] ;
99
+ newFileName = context . Request [ "newFileName" ] ;
100
100
}
101
101
102
- var pWidth = imageW ;
103
- var pHeight = imageH ;
102
+ var width = imageW ;
103
+ var height = imageH ;
104
104
105
105
var img = ( Bitmap ) Image . FromFile ( context . Server . MapPath ( imgSource ) ) ;
106
106
107
107
// Resize
108
- var imageP = this . ResizeImage ( img , Convert . ToInt32 ( pWidth ) , Convert . ToInt32 ( pHeight ) ) ;
108
+ var imageP = this . ResizeImage ( img , Convert . ToInt32 ( width ) , Convert . ToInt32 ( height ) ) ;
109
109
110
110
// Rotate if angle is not 0.00 or 360
111
111
if ( angle > 0.0F && angle < 360.00F )
112
112
{
113
113
imageP = ( Bitmap ) RotateImage ( imageP , angle ) ;
114
- pWidth = imageP . Width ;
115
- pHeight = imageP . Height ;
114
+ width = imageP . Width ;
115
+ height = imageP . Height ;
116
116
}
117
117
118
118
// Calculate Coords of the Image into the ViewPort
@@ -121,26 +121,26 @@ public void ProcessRequest(HttpContext context)
121
121
float srcY ;
122
122
float dstY ;
123
123
124
- if ( pWidth > viewPortW )
124
+ if ( width > viewPortW )
125
125
{
126
- srcX = Math . Abs ( imageX - Math . Abs ( ( imageW - pWidth ) / 2 ) ) ;
126
+ srcX = Math . Abs ( imageX - Math . Abs ( ( imageW - width ) / 2 ) ) ;
127
127
dstX = 0 ;
128
128
}
129
129
else
130
130
{
131
131
srcX = 0 ;
132
- dstX = imageX + ( ( imageW - pWidth ) / 2 ) ;
132
+ dstX = imageX + ( ( imageW - width ) / 2 ) ;
133
133
}
134
134
135
- if ( pHeight > viewPortH )
135
+ if ( height > viewPortH )
136
136
{
137
- srcY = Math . Abs ( imageY - Math . Abs ( ( imageH - pHeight ) / 2 ) ) ;
137
+ srcY = Math . Abs ( imageY - Math . Abs ( ( imageH - height ) / 2 ) ) ;
138
138
dstY = 0 ;
139
139
}
140
140
else
141
141
{
142
142
srcY = 0 ;
143
- dstY = imageY + ( ( imageH - pHeight ) / 2 ) ;
143
+ dstY = imageY + ( ( imageH - height ) / 2 ) ;
144
144
}
145
145
146
146
// Get Image viewed into the ViewPort
@@ -149,20 +149,20 @@ public void ProcessRequest(HttpContext context)
149
149
// Get Selector Portion
150
150
imageP = ImageCopy ( imageP , 0 , 0 , selectorX , selectorY , selectorW , selectorH ) ;
151
151
152
- if ( bSaveFile )
152
+ if ( saveFile )
153
153
{
154
154
context . Response . ContentType = "text/plain" ;
155
155
156
156
var sourceFilePath = context . Server . MapPath ( imgSource ) ;
157
- var sourceFolder = sourceFilePath . Remove ( sourceFilePath . LastIndexOf ( "\\ " ) ) ;
157
+ var sourceFolder = sourceFilePath . Remove ( sourceFilePath . LastIndexOf ( "\\ " , StringComparison . Ordinal ) ) ;
158
158
159
159
if ( PortalSettings . Current != null && ! this . HasWritePermission (
160
160
PathUtils . Instance . GetRelativePath ( PortalSettings . Current . PortalId , sourceFolder ) ) )
161
161
{
162
162
throw new SecurityException ( "You don't have write permission to save files under this folder." ) ;
163
163
}
164
164
165
- imageP . Save ( GenerateName ( sNewFileName , context . Server . MapPath ( imgSource ) ) ) ;
165
+ imageP . Save ( GenerateName ( newFileName , context . Server . MapPath ( imgSource ) ) ) ;
166
166
}
167
167
else
168
168
{
@@ -214,9 +214,8 @@ private static string GenerateName(string sNewFileName, string sSourceFullPath)
214
214
var sNewFilePath = ! string . IsNullOrEmpty ( sNewFileName )
215
215
? Path . Combine ( sSourcePath , sNewFileName + sExtension )
216
216
: Path . Combine (
217
- sSourcePath ,
218
- string . Format (
219
- "{0}_crop{1}" , Path . GetFileNameWithoutExtension ( sSourceFullPath ) , sExtension ) ) ;
217
+ sSourcePath ,
218
+ $ "{ Path . GetFileNameWithoutExtension ( sSourceFullPath ) } _crop{ sExtension } ") ;
220
219
221
220
var iCounter = 0 ;
222
221
@@ -227,7 +226,8 @@ private static string GenerateName(string sNewFileName, string sSourceFullPath)
227
226
var sFileNameNoExt = Path . GetFileNameWithoutExtension ( sNewFilePath ) ;
228
227
229
228
sNewFilePath = Path . Combine (
230
- sSourcePath , string . Format ( "{0}_{1}{2}" , sFileNameNoExt , iCounter , sExtension ) ) ;
229
+ sSourcePath ,
230
+ $ "{ sFileNameNoExt } _{ iCounter } { sExtension } ") ;
231
231
}
232
232
233
233
return sNewFilePath ;
0 commit comments