(順時針)旋轉BW映像程式

來源:互聯網
上載者:User
/**Code adapted from CxImage (http://www.xdp.it/cximage.htm)*/static BYTE* Rotate90(BYTE *src, int src_width, int src_height, int bpp ) {int x, y, y2;int dst_width  = src_height;int dst_height = src_width;// get src and dst scan widthint src_pitch  = (src_width*bpp + 7) /8 + 3 & ~3; int dst_pitch  = (dst_width*bpp + 7) /8 + 3 & ~3;// allocate dst imageBYTE *dst =  new BYTE[dst_pitch * dst_height];if(NULL == dst) return NULL;if(bpp == 1) {// speedy rotate for BW imagesBYTE *sbits, *dbits, *dbitsmax, bitpos, *nrow, *srcdisp;div_t div_r;BYTE *bsrc  = src; BYTE *bdest = dst;dbitsmax = bdest + dst_height * dst_pitch - 1;for(y = 0; y < src_height; y++) {// figure out the column we are going to be copying todiv_r = div(y, 8);// set bit pos of src column bytebitpos = (BYTE)(128 >> div_r.rem);srcdisp = bsrc + y * src_pitch;for (x = 0; x < src_pitch; x++) {// get source bitssbits = srcdisp + x;// get destination columnnrow = bdest + (dst_height - 1 - (x * 8)) * dst_pitch + div_r.quot;for (int z = 0; z < 8; z++) {// get destination bytedbits = nrow - z * dst_pitch;if ((dbits < bdest) || (dbits > dbitsmax)) break;if (*sbits & (128 >> z)) *dbits |= bitpos;}}}}else if((bpp == 8) || (bpp == 24) || (bpp == 32)) {}return dst;}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.