亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? utils.cpp

?? 幾種圖像格式之間的轉換
?? CPP
字號:
/*M///////////////////////////////////////////////////////////////////////////////////////
//
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//  By downloading, copying, installing or using the software you agree to this license.
//  If you do not agree to this license, do not download, install,
//  copy or use the software.
//
//
//                        Intel License Agreement
//                For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//   * Redistribution's of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//
//   * Redistribution's in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//
//   * The name of Intel Corporation may not be used to endorse or promote products
//     derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/

#include <assert.h>
#include "../include/utils.h"

#define  SCALE  14
#define  cR  (int)(0.299*(1 << SCALE) + 0.5)
#define  cG  (int)(0.587*(1 << SCALE) + 0.5)
#define  cB  ((1 << SCALE) - cR - cG)


void CvtBGRToGray( const uchar* bgr, uchar* gray, int len )
{
    int i;
    for( i = 0; i < len; i++, bgr += 3 )
    {
        int t = descale( bgr[0]*cB + bgr[1]*cG + bgr[2]*cR, SCALE );
        assert( (unsigned)t <= 255 );
        gray[i] = (uchar)t;
    }
}


void CvtRGBToGray( const uchar* rgb, uchar* gray, int len )
{
    int i;
    for( i = 0; i < len; i++, rgb += 3 )
    {
        int t = descale( rgb[2]*cB + rgb[1]*cG + rgb[0]*cR, SCALE );
        assert( (unsigned)t <= 255 );
        gray[i] = (uchar)t;
    }
}


void CvtBGRAToGray( const uchar* bgra, uchar* gray, int len )
{
    int i;
    for( i = 0; i < len; i++, bgra += 4 )
    {
        int t = descale( bgra[0]*cB + bgra[1]*cG + bgra[2]*cR, SCALE );
        assert( (unsigned)t <= 255 );
        gray[i] = (uchar)t;
    }
}


void CvtRGBAToGray( const uchar* rgba, uchar* gray, int len )
{
    int i;
    for( i = 0; i < len; i++, rgba += 4 )
    {
        int t = descale( rgba[2]*cB + rgba[1]*cG + rgba[0]*cR, SCALE );
        assert( (unsigned)t <= 255 );
        gray[i] = (uchar)t;
    }
}


void CvtRGBToBGR( const uchar* rgb, uchar* bgr, int len )
{
    int i;

    for( i = 0; i < len; i++, rgb += 3, bgr += 3 )

    {
        uchar b = rgb[2], g = rgb[1], r = rgb[0];
        bgr[0] = b;
        bgr[1] = g;
        bgr[2] = r;
    }
}


void  CvtBGRAToBGR( const uchar* bgra, uchar* bgr, int len )
{
    for( int i = 0; i < len; i++, bgra += 4, bgr += 3 )
    {
        uchar b = bgra[0], g = bgra[1], r = bgra[2];
        bgr[0] = b;
        bgr[1] = g;
        bgr[2] = r;
    }
}


void  CvtRGBAToBGR( const uchar* rgba, uchar* bgr, int len )
{
    for( int i = 0; i < len; i++, rgba += 4, bgr += 3 )
    {
        uchar b = rgba[2], g = rgba[1], r = rgba[0];
        bgr[0] = b;
        bgr[1] = g;
        bgr[2] = r;
    }
}


void CvtPaletteToGray( const PaletteEntry* palette, uchar* grayPalette, int entries )
{
    int i;
    for( i = 0; i < entries; i++ )
    {
        CvtBGRToGray( (uchar*)(palette + i), grayPalette + i, 1 );
    }
}


void  FillGrayPalette( PaletteEntry* palette, int bpp, bool negative )
{
    int i, length = 1 << bpp;
    int xor_mask = negative ? 255 : 0;

    for( i = 0; i < length; i++ )
    {
        int val = (i * 255/(length - 1)) ^ xor_mask;
        palette[i].b = palette[i].g = palette[i].r = (uchar)val;
        palette[i].a = 0;
    }
}


bool  IsColorPalette( PaletteEntry* palette, int bpp )
{
    int i, length = 1 << bpp;

    for( i = 0; i < length; i++ )
    {
        if( palette[i].b != palette[i].g ||
            palette[i].b != palette[i].r )
            return true;
    }

    return false;
}


void CalcShifts( uchar* data, uchar* line_end, int width3,
                 int y, int height, int& x_shift3, int& y_shift )
{
    int x3 = data - (line_end - width3);
    int new_x3 = x3 + x_shift3;
    
    y_shift = new_x3 / width3;
    new_x3 -= y_shift * width3;

    if( new_x3 == 0 )
    {
        y_shift--;
        new_x3 = width3;
    }

    x_shift3 = new_x3 - x3;

    if( y + y_shift >= height )
    {
        if( y + y_shift > height )
            y_shift = height - y;
        if( width3 - (line_end - data) + x_shift3 > 0 )
            x_shift3 = (line_end - data) - width3;
    }
}


uchar* FillUniColor( uchar* data, uchar*& line_end,
                     int step, int width3,
                     int& y, int height,
                     int count3, PaletteEntry clr )
{
    do
    {
        uchar* end = data + count3;

        if( end > line_end )
            end = line_end;

        count3 -= end - data;
        
        for( ; data < end; data += 3 )
        {
            WRITE_PIX( data, clr );
        }

        if( data >= line_end )
        {
            line_end += step;
            data = line_end - width3;
            if( ++y >= height  ) break;
        }
    }
    while( count3 > 0 );

    return data;
}


uchar* FillUniGray( uchar* data, uchar*& line_end,
                    int step, int width,
                    int& y, int height,
                    int count, uchar clr )
{
    do
    {
        uchar* end = data + count;

        if( end > line_end )
            end = line_end;

        count -= end - data;
        
        for( ; data < end; data++ )
        {
            *data = clr;
        }

        if( data >= line_end )
        {
            line_end += step;
            data = line_end - width;
            if( ++y >= height  ) break;
        }
    }
    while( count > 0 );

    return data;
}


uchar* FillColorRow8( uchar* data, uchar* indices, int len, PaletteEntry* palette )
{
    uchar* end = data + len*3;
    while( (data += 3) < end )
    {
        *((PaletteEntry*)(data-3)) = palette[*indices++];
    }
    PaletteEntry clr = palette[indices[0]];
    WRITE_PIX( data - 3, clr );
    return data;
}
                       

uchar* FillGrayRow8( uchar* data, uchar* indices, int len, uchar* palette )
{
    int i;
    for( i = 0; i < len; i++ )
    {
        data[i] = palette[indices[i]];
    }
    return data + len;
}


uchar* FillColorRow4( uchar* data, uchar* indices, int len, PaletteEntry* palette )
{
    uchar* end = data + len*3;

    while( (data += 6) < end )
    {
        int idx = *indices++;
        *((PaletteEntry*)(data-6)) = palette[idx >> 4];
        *((PaletteEntry*)(data-3)) = palette[idx & 15];
    }

    int idx = indices[0];
    PaletteEntry clr = palette[idx >> 4];
    WRITE_PIX( data - 6, clr );

    if( data == end )
    {
        clr = palette[idx & 15];
        WRITE_PIX( data - 3, clr );
    }
    return end;
}


uchar* FillGrayRow4( uchar* data, uchar* indices, int len, uchar* palette )
{
    uchar* end = data + len;
    while( (data += 2) < end )
    {
        int idx = *indices++;
        data[-2] = palette[idx >> 4];
        data[-1] = palette[idx & 15];
    }

    int idx = indices[0];
    uchar clr = palette[idx >> 4];
    data[-2] = clr;

    if( data == end )
    {
        clr = palette[idx & 15];
        data[-1] = clr;
    }
    return end;
}


uchar* FillColorRow1( uchar* data, uchar* indices, int len, PaletteEntry* palette )
{
    uchar* end = data + len*3;

    while( (data += 24) < end )
    {
        int idx = *indices++;
        *((PaletteEntry*)(data - 24)) = palette[(idx & 128) != 0];
        *((PaletteEntry*)(data - 21)) = palette[(idx & 64) != 0];
        *((PaletteEntry*)(data - 18)) = palette[(idx & 32) != 0];
        *((PaletteEntry*)(data - 15)) = palette[(idx & 16) != 0];
        *((PaletteEntry*)(data - 12)) = palette[(idx & 8) != 0];
        *((PaletteEntry*)(data - 9)) = palette[(idx & 4) != 0];
        *((PaletteEntry*)(data - 6)) = palette[(idx & 2) != 0];
        *((PaletteEntry*)(data - 3)) = palette[(idx & 1) != 0];
    }
    
    int idx = indices[0] << 24;
    for( data -= 24; data < end; data += 3, idx += idx )
    {
        PaletteEntry clr = palette[idx < 0];
        WRITE_PIX( data, clr );
    }

    return data;
}


uchar* FillGrayRow1( uchar* data, uchar* indices, int len, uchar* palette )
{
    uchar* end = data + len;

    while( (data += 8) < end )

    {
        int idx = *indices++;
        *((uchar*)(data - 8)) = palette[(idx & 128) != 0];
        *((uchar*)(data - 7)) = palette[(idx & 64) != 0];
        *((uchar*)(data - 6)) = palette[(idx & 32) != 0];
        *((uchar*)(data - 5)) = palette[(idx & 16) != 0];
        *((uchar*)(data - 4)) = palette[(idx & 8) != 0];
        *((uchar*)(data - 3)) = palette[(idx & 4) != 0];
        *((uchar*)(data - 2)) = palette[(idx & 2) != 0];
        *((uchar*)(data - 1)) = palette[(idx & 1) != 0];
    }
    
    int idx = indices[0] << 24;
    for( data -= 8; data < end; data++, idx += idx )
    {
        data[0] = palette[idx < 0];
    }

    return data;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91玉足脚交白嫩脚丫在线播放| 国产日韩欧美精品一区| 亚洲欧洲成人自拍| 精品一区二区国语对白| 日韩欧美一区二区视频| 五月天一区二区| 国产成人综合网站| 久久久www成人免费毛片麻豆| 理论片日本一区| 日韩三级伦理片妻子的秘密按摩| 日韩精品视频网站| 欧美一区二区免费视频| 免费不卡在线观看| 欧美大片日本大片免费观看| 免费人成精品欧美精品| 日韩精品资源二区在线| 激情综合色播五月| 久久久欧美精品sm网站| 成人午夜精品一区二区三区| 国产精品福利一区二区| 国产99久久精品| 国产精品黄色在线观看| 国产精品一区二区在线看| 国产亚洲欧洲一区高清在线观看| 成人理论电影网| 亚洲精品免费看| 在线免费观看不卡av| 亚洲一区二区三区小说| 欧美一区2区视频在线观看| 美国av一区二区| 国产午夜久久久久| 91色在线porny| 午夜精品福利一区二区三区蜜桃| 51精品国自产在线| 精品亚洲aⅴ乱码一区二区三区| 久久久蜜臀国产一区二区| 91视频在线看| 日韩高清欧美激情| 国产日韩欧美高清| 欧美性受极品xxxx喷水| 日韩电影在线观看电影| 国产婷婷色一区二区三区| 成人国产精品视频| 国产福利一区二区三区在线视频| 中文字幕国产一区二区| 欧美性色黄大片手机版| 日本网站在线观看一区二区三区| 久久久不卡网国产精品二区| 欧美综合一区二区三区| 久久99精品国产麻豆婷婷| 久久理论电影网| 欧美亚州韩日在线看免费版国语版| 国产真实精品久久二三区| 亚洲男同性恋视频| 精品国产一区二区国模嫣然| 国产网站一区二区| 欧美日韩一区二区欧美激情| 国产原创一区二区| 亚洲成人激情社区| 国产精品麻豆久久久| 国产精品一区专区| 亚洲成人三级小说| 国产精品丝袜久久久久久app| 欧美精品九九99久久| 亚洲午夜在线视频| 中文字幕 久热精品 视频在线| 欧美性受极品xxxx喷水| 成人爱爱电影网址| 精品无人码麻豆乱码1区2区| 午夜精品福利一区二区蜜股av| 国产精品国产三级国产普通话99| 日韩欧美国产一区二区在线播放| 在线免费观看一区| 波多野洁衣一区| 国产精品自拍一区| 亚洲欧洲日韩在线| 91蝌蚪porny九色| 国产成人av电影| 国产成人综合视频| 激情综合色综合久久综合| 免费高清视频精品| 婷婷国产v国产偷v亚洲高清| 洋洋成人永久网站入口| ...xxx性欧美| 国产欧美视频一区二区三区| 久久精品一区二区三区不卡牛牛| 欧美一区二区三区日韩视频| 欧美日韩激情一区二区三区| 色综合久久88色综合天天免费| 福利一区二区在线| 成人免费视频视频在线观看免费| 国内外精品视频| 久久精品久久综合| 精品在线免费视频| 美国十次了思思久久精品导航| 免费的成人av| 日本不卡视频在线| 日韩不卡手机在线v区| 午夜精品一区二区三区三上悠亚| 性久久久久久久久久久久| 亚洲第一主播视频| 日本成人在线看| 捆绑调教美女网站视频一区| 久久国产欧美日韩精品| 精品一区二区精品| 成人精品视频一区二区三区 | 日韩欧美123| 欧美电影在线免费观看| 欧美一区二区播放| 久久午夜色播影院免费高清| 久久久国产精品不卡| 国产精品美女久久久久av爽李琼| 国产精品久久久久久久久免费相片| 中文字幕在线观看不卡| 尤物在线观看一区| 亚洲无线码一区二区三区| 亚洲电影第三页| 蜜桃久久久久久| 福利视频网站一区二区三区| 色偷偷88欧美精品久久久| 欧美日韩国产精品自在自线| 日韩午夜电影在线观看| 国产亚洲欧洲997久久综合| 亚洲欧洲av一区二区三区久久| 亚洲在线中文字幕| 婷婷国产v国产偷v亚洲高清| 韩国成人精品a∨在线观看| 大胆欧美人体老妇| 色吧成人激情小说| 日韩你懂的电影在线观看| 日本一区二区在线不卡| 亚洲精品五月天| 麻豆国产欧美日韩综合精品二区| 岛国精品一区二区| 欧美色区777第一页| 91麻豆精品久久久久蜜臀| 欧美一区二区不卡视频| 国产精品二三区| 日韩电影免费一区| 成人美女视频在线观看| 欧美在线制服丝袜| 2020国产成人综合网| 亚洲制服丝袜av| 国产精品一区二区久久不卡| 欧美日韩中字一区| 久久精品网站免费观看| 亚洲女同女同女同女同女同69| 另类小说综合欧美亚洲| 在线免费不卡视频| 国产日产欧产精品推荐色| 日韩影院在线观看| 99精品视频在线播放观看| 欧美大片日本大片免费观看| 亚洲一线二线三线视频| 成人美女在线视频| 欧美成人精品3d动漫h| 精品成人一区二区三区| 国产精品情趣视频| 国产一区二区美女| 精品日韩欧美在线| 久久成人免费电影| 制服视频三区第一页精品| 亚洲成av人片| 欧美日韩日本视频| 亚洲1区2区3区视频| 欧美伊人久久久久久午夜久久久久| 亚洲手机成人高清视频| 一本久久a久久精品亚洲| 国产精品久久久久久亚洲伦| 成人18视频在线播放| 中文字幕一区二区不卡| 91玉足脚交白嫩脚丫在线播放| 亚洲女同一区二区| 欧美亚洲高清一区| 午夜电影一区二区三区| 91精品国产综合久久精品图片| 日本va欧美va精品| 欧美va亚洲va在线观看蝴蝶网| 国内欧美视频一区二区| 国产欧美一区二区精品忘忧草| youjizz久久| 亚洲一区在线观看免费观看电影高清| 色婷婷久久久综合中文字幕 | 亚洲精品一二三区| 在线观看www91| 日韩在线一区二区三区| 久久久综合精品| proumb性欧美在线观看| 一区二区三区四区不卡视频| 欧美女孩性生活视频| 激情文学综合丁香| 日韩伦理av电影| 欧美电影一区二区| 国产一区欧美日韩| 日韩一区欧美一区| 欧美片网站yy| 国产成人精品免费看| 一区二区三区蜜桃网| 日韩一区二区电影网| 成人成人成人在线视频|