(1) scanf("%d%d%d",red,green,blue); //輸入三個(gè)值

成都創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司一直秉承“誠(chéng)信做人,踏實(shí)做事”的原則,不欺瞞客戶,是我們最起碼的底線! 以服務(wù)為基礎(chǔ),以質(zhì)量求生存,以技術(shù)求發(fā)展,成交一個(gè)客戶多一個(gè)朋友!專注中小微企業(yè)官網(wǎng)定制,成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì),塑造企業(yè)網(wǎng)絡(luò)形象打造互聯(lián)網(wǎng)企業(yè)效應(yīng)。
(2) red = red%256;
blue =blue%256;
green = green%256;//將數(shù)據(jù)轉(zhuǎn)換到0~255之間
(3)rgb = red | (green8) | (blue16);//通過或運(yùn)算將數(shù)據(jù)放到對(duì)應(yīng)位置上
(4)0x%x //以16進(jìn)制輸出數(shù)據(jù)
# include stdio.h
//計(jì)算樣品深度
int sampleDepth(int x)
{
return (x-1)/2;
}
int main()
{
int i=0;
printf("獲取到的樣品深度是:");
scanf("%d",i);
printf("顏色強(qiáng)度%d\r\n",sampleDepth(i));
return 0;
}
原型:
int WINAPI icePub_getImgfilePColor(char *strImgFilename,int x,int y,char *strR,char *strG,char *strB,int flag)
輸入:strImgFilename 待處理的圖片文件名
x x坐標(biāo)
y y坐標(biāo)
flag 輸出RGB值的格式,0 10進(jìn)制,1 16進(jìn)制
輸出:strR R值
strG G值
strB B值
返回碼:0 OK;-2 x,y值超出圖片長(zhǎng)寬
int retCode=-1;
char strR[128],strG[128],strB[128];
Cstring m_mem;
typedef int (WINAPI ICEPUB_GETIMGFILEPCOLOR)(char *strImgFilename,int x,int y,char *strR,char *strG,char *strB,int flag);
ICEPUB_GETIMGFILEPCOLOR *icePub_getImgfilePColor = 0;
HINSTANCE hDLLDrv = LoadLibrary("icePubDll.dll");
if(hDLLDrv)
icePub_getImgfilePColor = (ICEPUB_GETIMGFILEPCOLOR *)GetProcAddress(hDLLDrv, "icePub_getImgfilePColor");
if(icePub_getImgfilePColor)
retCode=icePub_getImgfilePColor("a.jpg",100,55,strR,strG,strB,0);
if(hDLLDrv)
FreeLibrary(hDLLDrv);
if(retCode == 0)
m_mem.Format("(x,y):%d,%d\r\nR:%s\r\nG:%s\r\nB:%s",point.x,point.y,strR,strG,strB);
AfxMessageBox(m_mem);
原型:
int WINAPI icePub_imgToFileTextdata(char *strImgFilename,char *strFilename,char *strFenge,int flag)
輸入:strImgFilename 待處理圖像文件 (會(huì)被強(qiáng)制256級(jí)灰度化)
strFilename 待生成BMP文本數(shù)據(jù)文件名
strFenge 列之間分隔符
flag 文本數(shù)據(jù)格式標(biāo)志:0 10進(jìn)制; 1 16進(jìn)制; 10 RGB16進(jìn)制
輸出:
extern "C"
{
__declspec(dllexport)
int WINAPI icePub_imgToFileTextdata(char *strImgFilename,char *strFilename,char *strFenge,int flag);
}
#pragma comment(lib,"icePubDll.lib")
icePub_imgToFileTextdata("a.jpg","bmpdata.txt",",",0);
原型:
char * WINAPI icePub_getBufferFromImg2(char *strImgFilename,int *width,int *height,int huiGrade)
輸入:strImgFilename 圖片文件名
huiGrade 圖像灰度化標(biāo)志,0 no; 1 and =256 灰度級(jí)
輸出:width 圖像寬度
height 圖像高度
返回值:圖像的點(diǎn)陣數(shù)據(jù)(按照24位BMP格式)
extern "C"
{
__declspec(dllexport)
char * WINAPI icePub_getBufferFromImg2(char *strImgFilename,int *width,int *height,int huiGrade);
}
#pragma comment(lib,"icePubDll.lib")
char *bmpBuffer=NULL;
int imgWidth, imgHeight;
bmpBuffer = icePub_getBufferFromImg2 ("e:\\a.jpg",imgWidth,imgHeight,0);
//然后對(duì)bmpBuffer數(shù)據(jù)處理即可
if(bmpBuffer != NULL)
free(bmpBuffer);
可以使用CreateWindow函數(shù)。
CreateWindow,Windows API宏, 在WinUser.h中根據(jù)是否已定義Unicode被分別定義為CreateWindowW和CreateWindowA,后兩者又被分別定義為對(duì)CreateWindowExW和CreateWindowExA函數(shù)的調(diào)用。
pData里面保存的就是一個(gè)一個(gè)的COLORREF結(jié)構(gòu),你只需要通過BITMAPINFOHEADER中的寬高等信息,計(jì)算位移,就可以讀取某個(gè)點(diǎn)的RGB值了。
還有一個(gè)簡(jiǎn)單的辦法,你之前已經(jīng)有memBitmap這個(gè)CBitmap了,通過這個(gè)做更方便。通過SelectObject將memBitmap放到一個(gè)CDC中,直接使用函數(shù)GetPixel函數(shù)就可以獲取指定某個(gè)點(diǎn)的RGB值了,這個(gè)不需要計(jì)算和位移。
網(wǎng)站標(biāo)題:c語言中有rgb函數(shù)嗎,rgb函數(shù)是什么意思
當(dāng)前路徑:http://chinadenli.net/article44/dsgdiee.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、企業(yè)網(wǎng)站制作、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)公司、全網(wǎng)營(yíng)銷推廣、網(wǎng)站內(nèi)鏈
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)