首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 嵌入开发 > WinCE >

!救-evc下位图的操作,包括旋转90,180°还有颜色调节等等!解决方案

2012-02-12 
!!!急救---evc下位图的操作,包括旋转90,180,还有颜色调节等等!最近在做一个画图的程序,遇到位图旋转这个问

!!!急救---evc下位图的操作,包括旋转90,180°,还有颜色调节等等!
最近在做一个画图的程序,遇到位图旋转这个问题,现在解决不了拉,哪位大虾有旋转的好方法啊?有源码更好啊?
还有就是位图的颜色调节,反色、色阶调节等。
谁做过近似的程序啊,请赐教啊?感激啊!
我邮箱:
htysyyc@126.com,一起讨论啊!

[解决办法]
找资料噻,要讨论没有几个星期也说不清了。
[解决办法]
前一段时间做过一个操作图片的旋转等的程序。参考源代码是在网上找的,不能提供。因为是公司的。
[解决办法]
色阶调节没做过,其他的都不是很难,找本图像编程方面的书,基本上都有
[解决办法]
我也在做,在网上找了好多资料,实验都没通过。哎!哪位高手有办法啊?
你解决了高手我啊。
共享!共享!共享!共享!共享!
我发现csdn的高手越来越少了,还是。。。
[解决办法]
--!这些都比较简单的,源码到处都是,记得有本书, <VC++ 图象处理> 配套源码很详细
[解决办法]
BOOL AdjustDIBColor(HDIB hDib, int nColorModel, int v1, int v2, int v3)
{
BYTE r, g, b, c, m, y, k;
int dr, dg, db, dc, dm, dy;
double dh, ds, dv, dl, h, s, v, l;

if (hDib == NULL)
return FALSE;
BITMAPINFO *bmi = (BITMAPINFO *)GlobalLock(hDib);
if (! bmi)
return FALSE;

WaitCursorBegin();

switch (nColorModel)
{
case RGB_COLOR:
dr = v1;
dg = v2;
db = v3;
break;
case CMYK_COLOR:
dc = v1;
dm = v2;
dy = v3;
break;
case HSI_COLOR:
if (v1 < 0)
v1 += 360;
dh = v1;
ds = v2;
dv = v3;
break;
case HLS_COLOR:
if (v1 < 0)
v1 += 360;
dh = v1;
dl = v2/100.0;
ds = v3/100.0;
break;
}

// get color number
WORD wNumColors = DIBNumColors((LPBYTE)bmi);

if (wNumColors)// There is palette
{
WORD i;
switch (nColorModel)
{
case RGB_COLOR:
for (i=0; i <wNumColors; i++)
{
bmi-> bmiColors[i].rgbRed = BOUND(bmi-> bmiColors[i].rgbRed+dr, 0, 255);
bmi-> bmiColors[i].rgbGreen = BOUND(bmi-> bmiColors[i].rgbGreen+dg, 0, 255);
bmi-> bmiColors[i].rgbBlue = BOUND(bmi-> bmiColors[i].rgbBlue+db, 0, 255);
}
break;
case CMYK_COLOR:
for (i=0; i <wNumColors; i++)
{
r = bmi-> bmiColors[i].rgbRed;
g = bmi-> bmiColors[i].rgbGreen;
b = bmi-> bmiColors[i].rgbBlue;
RGBtoCMYK(r, g, b, &c, &m, &y, &k);
c += dc;
m += dm;
y += dy;
CMYKtoRGB(c, m, y, k, &r, &g, &b);
bmi-> bmiColors[i].rgbRed = r;
bmi-> bmiColors[i].rgbGreen = g;
bmi-> bmiColors[i].rgbBlue = b;
}
break;
case HSI_COLOR:
for (i=0; i <wNumColors; i++)
{
r = bmi-> bmiColors[i].rgbRed;
g = bmi-> bmiColors[i].rgbGreen;
b = bmi-> bmiColors[i].rgbBlue;
RGBtoHSI(r, g, b, &h, &s, &v);
h += dh;
s += ds;
v += dv;
HSItoRGB(h, s, v, &r, &g, &b);
bmi-> bmiColors[i].rgbRed = r;
bmi-> bmiColors[i].rgbGreen = g;
bmi-> bmiColors[i].rgbBlue = b;
}
break;
case HLS_COLOR:
for (i=0; i <wNumColors; i++)
{
r = bmi-> bmiColors[i].rgbRed;
g = bmi-> bmiColors[i].rgbGreen;
b = bmi-> bmiColors[i].rgbBlue;
RGBtoHLS(r, g, b, &h, &l, &s);
if (h != UNDEFINED)


h = BOUND(h+dh, 0.0, 360.0);
l = BOUND(l+dl, 0.0, 1.0);
s = BOUND(s+ds, 0.0, 1.0);
HLStoRGB(h, l, s, &r, &g, &b);
bmi-> bmiColors[i].rgbRed = r;
bmi-> bmiColors[i].rgbGreen = g;
bmi-> bmiColors[i].rgbBlue = b;
}
break;
}
}
else// No palette
{
// bits position
LPBITMAPINFOHEADER lpbi = (LPBITMAPINFOHEADER)bmi;
LPBYTE lpBits = (LPBYTE)lpbi + lpbi-> biSize;
int nDelta = WIDTHBYTES(lpbi-> biBitCount*lpbi-> biWidth) - lpbi-> biWidth*lpbi-> biBitCount/8;
int nx, ny;
switch (nColorModel)
{
case RGB_COLOR:
for (ny=0; ny <lpbi-> biHeight; ny++)
{
for (nx=0; nx <lpbi-> biWidth; nx++)
{
b = (BYTE)*(lpBits);
g = (BYTE)*(lpBits+1);
r = (BYTE)*(lpBits+2);
*lpBits++ = BOUND(b+db, 0, 255);
*lpBits++ = BOUND(g+dg, 0, 255);
*lpBits++ = BOUND(r+dr, 0, 255);
}
lpBits += nDelta;
}
break;
case CMYK_COLOR:
for (ny=0; ny <lpbi-> biHeight; ny++)
{
for (nx=0; nx <lpbi-> biWidth; nx++)
{
b = (BYTE)*(lpBits);
g = (BYTE)*(lpBits+1);
r = (BYTE)*(lpBits+2);
RGBtoCMYK(r, g, b, &c, &m, &y, &k);
c += dc;
m += dm;
y += dy;
CMYKtoRGB(c, m, y, k, &r, &g, &b);
*lpBits++ = b;
*lpBits++ = g;
*lpBits++ = r;
}
lpBits += nDelta;
}
break;
case HSI_COLOR:
for (ny=0; ny <lpbi-> biHeight; ny++)
{
for (nx=0; nx <lpbi-> biWidth; nx++)
{
b = (BYTE)*(lpBits);
g = (BYTE)*(lpBits+1);
r = (BYTE)*(lpBits+2);
RGBtoHSI(r, g, b, &h, &s, &v);
h += dh;
s += ds;
v += dv;
HSItoRGB(h, s, v, &r, &g, &b);
*lpBits++ = b;
*lpBits++ = g;
*lpBits++ = r;
}
lpBits += nDelta;
}
break;
case HLS_COLOR:
for (ny=0; ny <lpbi-> biHeight; ny++)
{
for (nx=0; nx <lpbi-> biWidth; nx++)
{
b = (BYTE)*(lpBits);
g = (BYTE)*(lpBits+1);
r = (BYTE)*(lpBits+2);
RGBtoHLS(r, g, b, &h, &l, &s);
if (h != UNDEFINED)
h = BOUND(h+dh, 0.0, 360.0);
l = BOUND(l+dl, 0.0, 1.0);
s = BOUND(s+ds, 0.0, 1.0);
HLStoRGB(h, l, s, &r, &g, &b);
*lpBits++ = b;
*lpBits++ = g;
*lpBits++ = r;
}
lpBits += nDelta;
}
break;
}
}

GlobalUnlock(hDib);
WaitCursorEnd();
return TRUE;
}

BOOL AdjustDIBBrightness(HDIB hDib, int v)
{
if (hDib == NULL)
return FALSE;
BITMAPINFO *bmi = (BITMAPINFO *)GlobalLock(hDib);
if (! bmi)
return FALSE;

WaitCursorBegin();

// get color number
WORD wNumColors = DIBNumColors((LPBYTE)bmi);

if (wNumColors)// There is palette
{
for (WORD i=0; i <wNumColors; i++)
{
ChangeBrightness(v,
&(bmi-> bmiColors[i].rgbRed),
&(bmi-> bmiColors[i].rgbGreen),
&(bmi-> bmiColors[i].rgbBlue));
}
}
else// No palette
{
// bits position
LPBITMAPINFOHEADER lpbi = (LPBITMAPINFOHEADER)bmi;
LPBYTE lpBits = (LPBYTE)lpbi + lpbi-> biSize;


int nDelta = WIDTHBYTES(lpbi-> biBitCount*lpbi-> biWidth) - lpbi-> biWidth*lpbi-> biBitCount/8;
BYTE r, g, b;
for (int ny=0; ny <lpbi-> biHeight; ny++)
{
for (int nx=0; nx <lpbi-> biWidth; nx++)
{
b = (BYTE)*(lpBits);
g = (BYTE)*(lpBits+1);
r = (BYTE)*(lpBits+2);
ChangeBrightness(v, &r, &g, &b);
*lpBits++ = b;
*lpBits++ = g;
*lpBits++ = r;
}
lpBits += nDelta;
}
}

GlobalUnlock(hDib);
WaitCursorEnd();
return TRUE;
}

BOOL AdjustDIBContrast(HDIB hDib, int v)
{
if (hDib == NULL)
return FALSE;
BITMAPINFO *bmi = (BITMAPINFO *)GlobalLock(hDib);
if (! bmi)
return FALSE;

WaitCursorBegin();

// get color number
WORD wNumColors = DIBNumColors((LPBYTE)bmi);

if (wNumColors)// There is palette
{
for (WORD i=0; i <wNumColors; i++)
{
ChangeContrast(v,
&(bmi-> bmiColors[i].rgbRed),
&(bmi-> bmiColors[i].rgbGreen),
&(bmi-> bmiColors[i].rgbBlue));
}
}
else// No palette
{
// bits position
LPBITMAPINFOHEADER lpbi = (LPBITMAPINFOHEADER)bmi;
LPBYTE lpBits = (LPBYTE)lpbi + lpbi-> biSize;
int nDelta = WIDTHBYTES(lpbi-> biBitCount*lpbi-> biWidth) - lpbi-> biWidth*lpbi-> biBitCount/8;
BYTE r, g, b;
for (int ny=0; ny <lpbi-> biHeight; ny++)
{
for (int nx=0; nx <lpbi-> biWidth; nx++)
{
b = (BYTE)*(lpBits);
g = (BYTE)*(lpBits+1);
r = (BYTE)*(lpBits+2);
ChangeContrast(v, &r, &g, &b);
*lpBits++ = b;
*lpBits++ = g;
*lpBits++ = r;
}
lpBits += nDelta;
}
}

GlobalUnlock(hDib);
WaitCursorEnd();
return TRUE;
}

热点排行