static void convert_to_index666(const SkBitmap& src, SkBitmap* dst) { SkPMColor storage[216]; SkPMColor* colors = storage; // rrr ggg bbb for (int r = 0; r < 6; r++) { int rr = conv_6_to_byte(r); for (int g = 0; g < 6; g++) { int gg = conv_6_to_byte(g); for (int b = 0; b < 6; b++) { int bb = conv_6_to_byte(b); *colors++ = SkPreMultiplyARGB(0xFF, rr, gg, bb); } } } SkColorTable* ctable = new SkColorTable(storage, 216); dst->allocPixels(SkImageInfo::Make(src.width(), src.height(), kIndex_8_SkColorType, kOpaque_SkAlphaType), NULL, ctable); ctable->unref(); SkAutoLockPixels alps(src); SkAutoLockPixels alpd(*dst); for (int y = 0; y < src.height(); y++) { const SkPMColor* srcP = src.getAddr32(0, y); uint8_t* dstP = dst->getAddr8(0, y); for (int x = src.width() - 1; x >= 0; --x) { *dstP++ = compute_666_index(*srcP++); } } }
static void convertToIndex666(const SkBitmap& src, SkBitmap* dst) { SkColorTable* ctable = new SkColorTable(216); SkPMColor* colors = ctable->lockColors(); // rrr ggg bbb for (int r = 0; r < 6; r++) { int rr = conv6ToByte(r); for (int g = 0; g < 6; g++) { int gg = conv6ToByte(g); for (int b = 0; b < 6; b++) { int bb = conv6ToByte(b); *colors++ = SkPreMultiplyARGB(0xFF, rr, gg, bb); } } } ctable->unlockColors(true); dst->setConfig(SkBitmap::kIndex8_Config, src.width(), src.height()); dst->allocPixels(ctable); ctable->unref(); SkAutoLockPixels alps(src); SkAutoLockPixels alpd(*dst); for (int y = 0; y < src.height(); y++) { const SkPMColor* srcP = src.getAddr32(0, y); uint8_t* dstP = dst->getAddr8(0, y); for (int x = src.width() - 1; x >= 0; --x) { *dstP++ = compute666Index(*srcP++); } } }
static void _hoc_alps(void) { double _r; double* _p; Datum* _ppvar; Datum* _thread; _NrnThread* _nt; if (_extcall_prop) {_p = _extcall_prop->param; _ppvar = _extcall_prop->dparam;}else{ _p = (double*)0; _ppvar = (Datum*)0; } _thread = _extcall_thread; _nt = nrn_threads; _r = alps ( _p, _ppvar, _thread, _nt, *getarg(1) ); hoc_retpushx(_r); }
static int trates ( double _lvm , double _la2 , double _lsh2 ) { double _la , _lb , _lc , _lqt ; _lqt = pow( q10 , ( ( celsius - 24.0 ) / 10.0 ) ) ; _la = trap0 ( _threadargscomma_ _lvm , tha + _lsh2 , Ra , qa ) ; _lb = trap0 ( _threadargscomma_ - _lvm , - tha - _lsh2 , Rb , qa ) ; mtau = 1.0 / ( _la + _lb ) / _lqt ; if ( mtau < mmin ) { mtau = mmin ; } minf = _la / ( _la + _lb ) ; _la = trap0 ( _threadargscomma_ _lvm , thi1 + _lsh2 , Rd , qd ) ; _lb = trap0 ( _threadargscomma_ - _lvm , - thi2 - _lsh2 , Rg , qg ) ; htau = 1.0 / ( _la + _lb ) / _lqt ; if ( htau < hmin ) { htau = hmin ; } hinf = 1.0 / ( 1.0 + exp ( ( _lvm - thinf - _lsh2 ) / qinf ) ) ; _lc = alpv ( _threadargscomma_ _lvm ) ; sinf = _lc + _la2 * ( 1.0 - _lc ) ; taus = bets ( _threadargscomma_ _lvm ) / ( a0s * ( 1.0 + alps ( _threadargscomma_ _lvm ) ) ) ; if ( taus < smax ) { taus = smax ; } return 0; }
static void _hoc_alps(void) { double _r; _r = alps ( *getarg(1) ); hoc_retpushx(_r); }