@@ -309,13 +309,88 @@ describe('Titanium.Blob', function () {
309
309
should ( b . height ) . be . eql ( 60 ) ;
310
310
} ) ;
311
311
312
+ it ( 'with PNG (square)' , function ( ) {
313
+ const blob = Ti . Filesystem . getFile ( 'Logo.png' ) . read ( ) ;
314
+ const b = blob . imageAsResized ( 50 , 50 ) ;
315
+ should ( b ) . be . an . Object ( ) ;
316
+ should ( b . width ) . be . eql ( 50 ) ;
317
+ should ( b . height ) . be . eql ( 50 ) ;
318
+ } ) ;
319
+
320
+ it ( 'with non-image (JS file) returns null' , function ( ) {
321
+ const blob = Ti . Filesystem . getFile ( 'app.js' ) . read ( ) ;
322
+ const b = blob . imageAsResized ( 50 , 60 ) ;
323
+ should . not . exist ( b ) ;
324
+ } ) ;
325
+ } ) ;
326
+
327
+ describe ( '#imageAsResized() - non square' , function ( ) {
328
+ it ( 'is a Function' , function ( ) {
329
+ const blob = Ti . Filesystem . getFile ( 'Logo_non_square.png' ) . read ( ) ;
330
+ should ( blob . imageAsResized ) . be . a . Function ( ) ;
331
+ } ) ;
332
+
333
+ it ( 'with PNG' , function ( ) {
334
+ const blob = Ti . Filesystem . getFile ( 'Logo_non_square.png' ) . read ( ) ;
335
+ const b = blob . imageAsResized ( 50 , 60 ) ;
336
+ should ( b ) . be . an . Object ( ) ;
337
+ should ( b . width ) . be . eql ( 50 ) ;
338
+ should ( b . height ) . be . eql ( 60 ) ;
339
+ } ) ;
340
+
341
+ it ( 'with PNG (square)' , function ( ) {
342
+ const blob = Ti . Filesystem . getFile ( 'Logo_non_square.png' ) . read ( ) ;
343
+ const b = blob . imageAsResized ( 50 , 50 ) ;
344
+ should ( b ) . be . an . Object ( ) ;
345
+ should ( b . width ) . be . eql ( 50 ) ;
346
+ should ( b . height ) . be . eql ( 50 ) ;
347
+ } ) ;
348
+
312
349
it ( 'with non-image (JS file) returns null' , function ( ) {
313
350
const blob = Ti . Filesystem . getFile ( 'app.js' ) . read ( ) ;
314
351
const b = blob . imageAsResized ( 50 , 60 ) ;
315
352
should . not . exist ( b ) ;
316
353
} ) ;
317
354
} ) ;
318
355
356
+ describe ( '#imageAsResized() from imageview' , function ( ) {
357
+ it ( 'square to non square' , function ( ) {
358
+ const img = Ti . UI . createImageView ( { image : 'Logo.png' } ) ;
359
+ const blob = img . toBlob ( ) ;
360
+ const b = blob . imageAsResized ( 50 , 60 ) ;
361
+ should ( b ) . be . an . Object ( ) ;
362
+ should ( b . width ) . be . eql ( 50 ) ;
363
+ should ( b . height ) . be . eql ( 60 ) ;
364
+ } ) ;
365
+
366
+ it ( 'non square to non square' , function ( ) {
367
+ const img = Ti . UI . createImageView ( { image : 'Logo_non_square.png' } ) ;
368
+ const blob = img . toBlob ( ) ;
369
+ const b = blob . imageAsResized ( 50 , 60 ) ;
370
+ should ( b ) . be . an . Object ( ) ;
371
+ should ( b . width ) . be . eql ( 50 ) ;
372
+ should ( b . height ) . be . eql ( 60 ) ;
373
+ } ) ;
374
+
375
+ it ( 'square to square' , function ( ) {
376
+ const img = Ti . UI . createImageView ( { image : 'Logo.png' } ) ;
377
+ const blob = img . toBlob ( ) ;
378
+ const b = blob . imageAsResized ( 60 , 60 ) ;
379
+ should ( b ) . be . an . Object ( ) ;
380
+ should ( b . width ) . be . eql ( 60 ) ;
381
+ should ( b . height ) . be . eql ( 60 ) ;
382
+ } ) ;
383
+
384
+ it ( 'non square to square' , function ( ) {
385
+ const img = Ti . UI . createImageView ( { image : 'Logo_non_square.png' } ) ;
386
+ const blob = img . toBlob ( ) ;
387
+ const b = blob . imageAsResized ( 60 , 60 ) ;
388
+ should ( b ) . be . an . Object ( ) ;
389
+ should ( b . width ) . be . eql ( 60 ) ;
390
+ should ( b . height ) . be . eql ( 60 ) ;
391
+ } ) ;
392
+ } ) ;
393
+
319
394
describe ( '#imageAsThumbnail()' , function ( ) {
320
395
it ( 'is a Function' , function ( ) {
321
396
const blob = Ti . Filesystem . getFile ( 'Logo.png' ) . read ( ) ;
0 commit comments