swift - What can I use instead of NSBitmapImageRep in iOS? (Water ripples example) -


i found interesting post water ripple simulation. includes xcode project little cocoa app osx. tried app running in ios using swift, couldn't find solution following problem:

the osx app uses nsbitmapimagerep draw bitmap data array onto screen (this happens in bbrippleview.m). unfortunately, nsbitmapimagerep not available in ios. tried using cgimage instead, "kind of working": can see kind of water ripples, split in weird way , don't move way supposed to. guess cgimage expects bitmap data in different format gets it.

edit: here ios rippleview class: rippleview.swift

edit 2: modified rippleview.swift

what right way implement following osx code segments in ios using swift?

        image = [[nsimage alloc] initwithsize:nsmakesize(cols, rows)];         bufrep = [[nsbitmapimagerep alloc]                             initwithbitmapdataplanes:null                             pixelswide:cols                             pixelshigh:rows                             bitspersample:8                             samplesperpixel:1                             hasalpha:no                             isplanar:yes                             colorspacename:nsdevicewhitecolorspace                             bytesperrow:0                             bitsperpixel:0];         [image addrepresentation:bufrep]; 

and

-(void)applybuffer {     unsigned char* data = [bufrep bitmapdata];     int x = 0;     int y = 0;     int position = 0;     ( y = 0; y < rows; y ++) {         ( x = 0; x < cols ; x ++) {             position = (y * cols) + x;             data[position] = (char)buffer2[position] << 1;         }                }        } 

you telling cgimagecreate image greyscale, 8 bits pixel. buffers arrays of ints, either 32 or 64 bits (4 or 8 bytes).

switch uint8, should lot.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -