aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDr Scofield2009-02-02 11:40:34 +0000
committerDr Scofield2009-02-02 11:40:34 +0000
commitb9db1b1345880ba524b8abb3cecd77754205a29b (patch)
tree96429e764b2ba69fdcac649400471cee3c4d6ea0
parent* Removed erroneous reference to the Data.Base Framework (diff)
downloadopensim-SC-b9db1b1345880ba524b8abb3cecd77754205a29b.zip
opensim-SC-b9db1b1345880ba524b8abb3cecd77754205a29b.tar.gz
opensim-SC-b9db1b1345880ba524b8abb3cecd77754205a29b.tar.bz2
opensim-SC-b9db1b1345880ba524b8abb3cecd77754205a29b.tar.xz
Merge branch 'vector' into OpenSimulator.org
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs163
1 files changed, 141 insertions, 22 deletions
diff --git a/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs
index ffbc262..cf83cc0 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs
@@ -128,34 +128,134 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
128 128
129 private void Draw(string data, UUID id, string extraParams) 129 private void Draw(string data, UUID id, string extraParams)
130 { 130 {
131 // TODO: this is a brutal hack. extraParams should actually be parsed reasonably. 131 // We need to cater for old scripts that didnt use extraParams neatly, they use either an integer size which represents both width and height, or setalpha
132 int size = 256; 132 // we will now support multiple comma seperated params in the form width:256,height:512,alpha:255
133 try 133 int width = 256;
134 { 134 int height = 256;
135 size = Convert.ToInt32(extraParams); 135 int alpha = 255; // 0 is transparent
136 } 136
137 catch (Exception e) 137 char[] paramDelimiter = { ',' };
138 char[] nvpDelimiter = { ':' };
139
140 extraParams = extraParams.Trim();
141 extraParams = extraParams.ToLower();
142
143 string[] nvps = extraParams.Split(paramDelimiter);
144
145 int temp = -1;
146 foreach (string pair in nvps)
138 { 147 {
139//Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used 148 string[] nvp = pair.Split(nvpDelimiter);
140 Console.WriteLine("Problem with Draw. Please verify parameters." + e.ToString()); 149 string name = "";
150 string value = "";
151
152 if (nvp[0] != null)
153 {
154 name = nvp[0].Trim();
155 }
156
157 if (nvp.Length==2)
158 {
159 value = nvp[1].Trim();
160 }
161
162 switch (name)
163 {
164 case "width":
165 temp = parseIntParam(value);
166 if (temp != -1)
167 {
168 if (temp < 1)
169 {
170 width = 1;
171 }
172 else if (temp > 2048)
173 {
174 width = 2048;
175 }
176 else
177 {
178 width = temp;
179 }
180 }
181 break;
182 case "height":
183 temp = parseIntParam(value);
184 if (temp != -1)
185 {
186 if (temp < 1)
187 {
188 height = 1;
189 }
190 else if (temp > 2048)
191 {
192 height = 2048;
193 }
194 else
195 {
196 height = temp;
197 }
198 }
199 break;
200 case "alpha":
201 temp = parseIntParam(value);
202 if (temp != -1)
203 {
204 if (temp < 0)
205 {
206 alpha = 0;
207 }
208 else if (temp > 255)
209 {
210 alpha = 255;
211 }
212 else
213 {
214 alpha = temp;
215 }
216 }
217 break;
218 case "":
219 // blank string has been passed do nothing just use defaults
220 break;
221 default: // this is all for backwards compat, all a bit ugly hopfully can be removed in future
222 // could be either set alpha or just an int
223 if (name == "setalpha")
224 {
225 alpha = 0; // set the texture to have transparent background (maintains backwards compat)
226 }
227 else
228 {
229 // this function used to accept an int on its own that represented both
230 // width and height, this is to maintain backwards compat, could be removed
231 // but would break existing scripts
232 temp = parseIntParam(name);
233 if (temp != -1)
234 {
235 if (temp > 1028)
236 temp = 1028;
237
238 if (temp < 128)
239 temp = 128;
240
241 width = temp;
242 height = temp;
243 }
244 }
245 break;
246 }
247
141 } 248 }
142 249
143 if ((size < 128) || (size > 1024)) 250 Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
144 size = 256;
145
146 Bitmap bitmap = new Bitmap(size, size, PixelFormat.Format32bppArgb);
147 251
148 Graphics graph = Graphics.FromImage(bitmap); 252 Graphics graph = Graphics.FromImage(bitmap);
149 253
150 extraParams = extraParams.ToLower(); 254 // this is really just to save people filling the
151 int alpha = 255; 255 // background white in their scripts, only do when fully opaque
152 if (extraParams == "setalpha") 256 if (alpha == 255)
153 { 257 {
154 alpha = 0; 258 graph.FillRectangle(new SolidBrush(Color.White), 0, 0, width, height);
155 }
156 else
157 {
158 graph.FillRectangle(new SolidBrush(Color.White), 0, 0, size, size);
159 } 259 }
160 260
161 for (int w = 0; w < bitmap.Width; w++) 261 for (int w = 0; w < bitmap.Width; w++)
@@ -182,6 +282,25 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
182 } 282 }
183 m_textureManager.ReturnData(id, imageJ2000); 283 m_textureManager.ReturnData(id, imageJ2000);
184 } 284 }
285
286 private int parseIntParam(string strInt)
287 {
288 int parsed;
289 try
290 {
291 parsed = Convert.ToInt32(strInt);
292 }
293 catch (Exception)
294 {
295 //Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used
296 // Console.WriteLine("Problem with Draw. Please verify parameters." + e.ToString());
297 parsed = -1;
298 }
299
300 return parsed;
301
302 }
303
185 304
186/* 305/*
187 private void CairoDraw(string data, System.Drawing.Graphics graph) 306 private void CairoDraw(string data, System.Drawing.Graphics graph)