@@ -202,11 +202,8 @@ private static void ProcessNinePatch(ImageInfo imageInfo)
202
202
image . Data = newData ;
203
203
}
204
204
205
- private static Packer PackImages ( string [ ] imageFiles )
205
+ private static Packer PackImages ( string [ ] imageFiles , int width , int height )
206
206
{
207
- var width = 256 ;
208
- var height = 256 ;
209
-
210
207
Console . WriteLine ( "Atlas Size: {0}x{1}" , width , height ) ;
211
208
212
209
var packer = new Packer ( width , height ) ;
@@ -263,7 +260,7 @@ private static Packer PackImages(string[] imageFiles)
263
260
264
261
private static byte [ ] BuildAtlasBitmap ( Packer packer )
265
262
{
266
- var bitmap = new byte [ packer . Width * packer . Height * 4 ] ;
263
+ var bitmap = new byte [ ( long ) packer . Width * packer . Height * 4 ] ;
267
264
foreach ( var packRectangle in packer . PackRectangles )
268
265
{
269
266
var imageInfo = ( ImageInfo ) packRectangle . Data ;
@@ -274,7 +271,7 @@ private static byte[] BuildAtlasBitmap(Packer packer)
274
271
for ( var y = 0 ; y < image . Height ; ++ y )
275
272
{
276
273
var sourcePos = ( y * image . Width ) * 4 ;
277
- var destPos = ( ( ( y + packRectangle . Y ) * packer . Width ) + packRectangle . X ) * 4 ;
274
+ var destPos = ( ( ( y + packRectangle . Y ) * ( long ) packer . Width ) + packRectangle . X ) * 4 ;
278
275
279
276
Array . Copy ( image . Data , sourcePos , bitmap , destPos , image . Width * 4 ) ;
280
277
}
@@ -348,7 +345,7 @@ private static XDocument CreateOutputXML(string outputFile, Packer packer)
348
345
return doc ;
349
346
}
350
347
351
- private static void Process ( string inputFolder , string outputFile )
348
+ private static void Process ( string inputFolder , string outputFile , int width , int height )
352
349
{
353
350
var outputType = DetermineOutputType ( outputFile ) ;
354
351
var imageFiles = GetImageFiles ( inputFolder ) ;
@@ -360,7 +357,7 @@ private static void Process(string inputFolder, string outputFile)
360
357
361
358
Console . WriteLine ( "{0} image files found at {1}." , imageFiles . Length , inputFolder ) ;
362
359
363
- var packer = PackImages ( imageFiles ) ;
360
+ var packer = PackImages ( imageFiles , width , height ) ;
364
361
365
362
// All images had been packed
366
363
// Now build up the atlas bitmap
@@ -384,13 +381,25 @@ public static void Main(string[] args)
384
381
{
385
382
if ( args . Length < 2 )
386
383
{
387
- Console . WriteLine ( "Usage: MyraTexturePacker.exe <input_folder> <output_file>" ) ;
384
+ Console . WriteLine ( "Usage: MyraTexturePacker.exe <input_folder> <output_file> [width] [height] " ) ;
388
385
return ;
389
386
}
390
387
391
388
try
392
389
{
393
- Process ( args [ 0 ] , args [ 1 ] ) ;
390
+ var width = 256 ;
391
+ if ( args . Length > 2 )
392
+ {
393
+ width = int . Parse ( args [ 2 ] ) ;
394
+ }
395
+
396
+ var height = 256 ;
397
+ if ( args . Length > 3 )
398
+ {
399
+ height = int . Parse ( args [ 3 ] ) ;
400
+ }
401
+
402
+ Process ( args [ 0 ] , args [ 1 ] , width , height ) ;
394
403
}
395
404
catch ( Exception ex )
396
405
{
0 commit comments