Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2695] iOS crop property to image views.

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:59:50.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.6.0
ComponentsiOS
Labelscrop, imageview, ios, release-1.6.0
ReporterPedro Enrique
AssigneeBlain Hamon
Created2011-04-15T03:27:15.000+0000
Updated2011-04-17T01:59:50.000+0000

Description

Feature request for cropping of images.
Several HD tickets are asking for this, most recent one being this one http://developer.appcelerator.com/helpdesk/view/62781">http://developer.appcelerator.com/helpdesk/view/62781

Comments

  1. Jeff Haynie 2011-04-15

    (from [8924a7783bf5dc7e7d5c3e478ce437b8f23eb199]) [#2695 state:in-progress] Implemented as a blob's imageAsCropped method. Takes one argument with width, height, x, and y properties. Test needs to be created before sending to fixed. https://github.com/appcelerator/titanium_mobile/commit/8924a7783bf5dc7e7d5c3e478ce437b8f23eb199"> https://github.com/appcelerator/titanium_mobile/commit/8924a7783bf5...

  2. Pedro Enrique 2011-04-15

    Tested on 1.6 with the following code and it works as expected:

       

       var cropImage = function(imageView,width,height,x,y){
           // with the var 'a' we avoid the image to triger the 'load' listener infinite times
           var a = 1;
           imageView.addEventListener('load',function(){
               if(a==1){
                   imageView.image = imageView.toBlob().imageAsCropped({width:width,height:height,x:x,y:y});
               }
               a++;
           });
       };
       // example:
       var win = Ti.UI.createWindow();
       win.backgroundColor=backgroundColor='#ccc';
       var imageWidth=180;
       var imageHeight=100;
       var imageX=200;
       var imageY=10;
       var photo = Ti.UI.createImageView({
           image:'http://www.google.com/images/logos/ps_logo2.png',
           top:50,
           left:120,
           width:imageWidth,
           height:imageHeight
       });
       cropImage(photo,imageWidth,imageHeight,imageX,imageY);
       win.add(photo);
       win.open();
       
       
       
       
    iPhone Simulator 4.2
  3. Stephen Tramer 2011-04-15

    Resolving ticket as per the above.

JSON Source