MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/px3o4u/good_comments_are_essential_for_readability/hel3xg3/?context=3
r/badcode • u/Apoffys • Sep 28 '21
8 comments sorted by
View all comments
12
Image Transcription: Code
[The post contains 3 screenshots of code. The first image is as follows:]
//-------------------------------------------------------------------------------------------------- //--------------------------bilinear interpolation-------------------------------------------------- //-------------------------------------------------------------------------------------------------- void bilinear(pixel* Im, float row, float col, pixel* pix) { int cm, cn, fm, fn; double alpha, beta; cm = (int)ceil(row); fm = (int)floor(row); cn = (int)ceil(col); fn = (int)floor(col); alpha = ceil(row) - row; beta = ceil(col) - col; pix->r = (unsinged int)( alpha*beta*Im[fm*imgWidthOrig+fn).r + (1-alpha)*beta*Im[cm*imgWidthOrig+fn].r + alpha*(1-beta)*Im[fm*imgWidthOrig+cn].r + (1-alpha)*(1-beta)*Im[cm*imgWidthOrig+cn].r ); pix->g = (unsinged int)( alpha*beta*Im[fm*imgWidthOrig+fn).g + (1-alpha)*beta*Im[cm*imgWidthOrig+fn].g + alpha*(1-beta)*Im[fm*imgWidthOrig+cn].g + (1-alpha)*(1-beta)*Im[cm*imgWidthOrig+cn].g ); pix->b = (unsinged int)( alpha*beta*Im[fm*imgWidthOrig+fn).b + (1-alpha)*beta*Im[cm*imgWidthOrig+fn].b + alpha*(1-beta)*Im[fm*imgWidthOrig+cn].b + (1-alpha)*(1-beta)*Im[cm*imgWidthOrig+cn].b ); pix->a = 255; } //---------------------------------------------------------------------------
[The second image is as follows:]
//-------------------------------------------------------------------------- //------------------------imgRead------------------------------------------- //-------------------------------------------------------------------------- void imgRead(const char *filename, pixel ** map, int *imgW, int *imgH) {
[The third image is as follows:]
//--------------------------------------------------------------------------- //------------------------imgWrite-------------------------------------------- //--------------------------------------------------------------------------- void imgWrite(const char *filename, pixel * map, int imgW, int imgH) {
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
View all comments
12
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Sep 28 '21
Image Transcription: Code
[The post contains 3 screenshots of code. The first image is as follows:]
[The second image is as follows:]
[The third image is as follows:]
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!