/*
Module : DIBIMAGE.CPP
Purpose: Implementation for an MFC class that encapsulates DIBs
and supports a variety of image manipulation functions on it
Created: PJN / DIBSECTION/1 / 23-07-1997
History: None
Copyright (c) 1997 by PJ Naughter.
All rights reserved.
*/
///////////////////////////////// Includes //////////////////////////////////
#include "stdafx.h"
#include "math.h"
#include "dibimage.h"
#include "resource.h"
////////////////////////////// Future additions ///////////////////////////////
/*
BOOL CDibImage::TraceContourFilter()
BOOL CDibImage::EqualizeHistogram()
BOOL CDibImage::StretchHistogram()
BOOL CDibImage::MosaicFilter(int BlockSize)
BOOL CDibImage::DespeckleFilter()
BOOL CDibImage::DilateFilter()
BOOL CDibImage::EmbossFilter()
BOOL CDibImage::ErodeFilter()
BOOL CDibImage::SoftenFilter()
BOOL CDibImage::SharpenFilter()
BOOL CDibImage::UnSharpenFilter()
BOOL CDibImage::Posterize(int BitsPerChannel)
BOOL CDibImage::Solerize(int Threshold)
BOOL CDibImage::CirleDeform()
BOOL CDibImage::HorizontalCylinderDeform()
BOOL CDibImage::VerticalCylinderDeform()
BOOL CDibImage::MotionBlurDeform()
BOOL CDibImage::PentagonDeform()
BOOL CDibImage::PerspectiveHorizontalDeform()
BOOL CDibImage::PerspectiveVerticalDeform()
BOOL CDibImage::PinchDeform()
BOOL CDibImage::PunchDeform()
BOOL CDibImage::SkewDeform()
BOOL CDibImage::WindDeform()
BOOL CDibImage::ModifyHistogram(int* TransformTable, int nSize);
BOOL CDibImage::Resize(const CSize& size);
BOOL CDibImage::Resample(const CSize& size);
static BOOL CDibImage::ArithmeticAdd(CDibImage& dib1, CDibImage& dib2, int Divisor, int Bias, BOOL bClip);
static BOOL CDibImage::ArithmeticSubtract(CDibImage& dib1, CDibImage& dib2, int Divisor, int Bias, BOOL bClip);
static BOOL CDibImage::ArithmeticMultiply(CDibImage& dib1, CDibImage& dib2, int Divisor, int Bias, BOOL bClip);
static BOOL CDibImage::ArithmeticDifference(CDibImage& dib1, CDibImage& dib2, int Divisor, int Bias, BOOL bClip);
static BOOL CDibImage::ArithmeticDarkest(CDibImage& dib1, CDibImage& dib2, int Divisor, int Bias, BOOL bClip);
static BOOL CDibImage::ArithmeticLightest(CDibImage& dib1, CDibImage& dib2, int Divisor, int Bias, BOOL bClip);
BOOL CDibImage::SpacialFilter();
*/
///////////////////////////////// defines /////////////////////////////////////
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//////////////////////////////// Implementation ///////////////////////////////
C3By3Filter::C3By3Filter()
{
//Default filter is a filter which will not do anything to the image
for (int i=0; i<3; i++)
for (int j=0; j<3; j++)
m_nValues[i][j] = 0;
m_nValues[1][1] = 1;
m_nDivision = 1;
m_nBias = 0;
}
COLORREF C3By3Filter::Filter(CDibImage& dibImage, LPSTR lpDibBits, int x, int y)
{
int r = 0;
int g = 0;
int b = 0;
for (int i=0; i<3; i++)
{
for (int j=0; j<3; j++)
{
COLORREF c;
if (dibImage.GetPixel(x+i-1, y+j-1, c, lpDibBits))
{
r += (m_nValues[i][j] * GetRValue(c));
g += (m_nValues[i][j] * GetGValue(c));
b += (m_nValues[i][j] * GetBValue(c));
}
}
}
ASSERT(m_nDivision);
r = min(r/m_nDivision + m_nBias, 255);
g = min(g/m_nDivision + m_nBias, 255);
b = min(b/m_nDivision + m_nBias, 255);
r = max(r, 0);
g = max(g, 0);
b = max(b, 0);
return RGB(r, g, b);
}
C3By3MedianFilter::C3By3MedianFilter()
{
}
COLORREF C3By3MedianFilter::Filter(CDibImage& dibImage, LPSTR lpDibBits, int x, int y)
{
int nPixels = 0;
for (int k=0; k<9; k++)
m_Ordered[k] = 0;
for (int i=0; i<3; i++)
{
for (int j=0; j<3; j++)
{
COLORREF c;
if (dibImage.GetPixel(x+i-1, y+j-1, c, lpDibBits))
{
m_Ordered[nPixels] = c;
nPixels++;
}
}
}
qsort(&m_Ordered, nPixels, sizeof(COLORREF), CompareFunc);
return m_Ordered[nPixels/2];
}
int C3By3MedianFilter::CompareFunc(const void *elem1, const void *elem2)
{
COLORREF c1 = *(COLORREF*)elem1;
COLORREF c2 = *(COLORREF*)elem2;
if (c1 == c2)
return 0;
else
{
BYTE r1 = GetRValue(c1);
BYTE g1 = GetGValue(c1);
BYTE b1 = GetBValue(c1);
BYTE r2 = GetRValue(c2);
BYTE g2 = GetGValue(c2);
BYTE b2 = GetBValue(c2);
if ((r1 + g1 + b1) > (r2 + g2 + b2))
return 1;
else
return -1;
}
}
C5By5Filter::C5By5Filter()
{
//Default filter is a filter which will not do anything to the image
for (int i=0; i<5; i++)
for (int j=0; j<5; j++)
m_nValues[i][j] = 0;
m_nValues[2][2] = 1;
m_nDivision = 1;
m_nBias = 0;
}
COLORREF C5By5Filter::Filter(CDibImage& dibImage, LPSTR lpDibBits, int x, int y)
{
int r = 0;
int g = 0;
int b = 0;
for (int i=0; i<5; i++)
{
for (int j=0; j<5; j++)
{
COLORREF c;
if (dibImage.GetPixel(x+i-2, y+j-2, c, lpDibBits))
{
r += (m_nValues[i][j] * GetRValue(c));
g += (m_nValues[i][j] * GetGValue(c));
b += (m_nValues[i][j] * GetBValue(c));
}
}
}
ASSERT(m_nDivision);
r = min(r/m_nDivision + m_nBias, 255);
g = min(g/m_nDivision + m_nBias, 255);
b = min(b/m_nDivision + m_nBias, 255);
r = max(r, 0);
g = max(g, 0);
b = max(b, 0);
return RGB(r, g, b);
}
C7By7Filter::C7By7Filter()
{
//Default filter is a filter which will not do anything to the image
for (int i=0; i<7; i++)
for (int j=0; j<7; j++)
m_nValues[i][j] = 0;
m_nValues[3][3] = 1;
m_nDivision = 1;
m_nBias = 0;
}
COLORREF C7By7Filter::Filter(CDibImage& dibImage, LPSTR lpDibBits, int x, int y)
{
int r = 0;
int g = 0;
int b = 0;
for (int i=0; i<7; i++)
{
for (int j=0; j<7; j++)
{
COLORREF c;
if (dibImage.GetPixel(x+i-3, y+j-3, c, lpDibBits))
{
r += (m_nValues[i][j] * GetRValue(c));
g += (m_nValues[i][j] * GetGValue(c));
b += (m_nValues[i][j] * GetBValue(c));
}
}
}
ASSERT(m_nDivision);
r = min(r/m_nDivision + m_nBias, 255);
g = min(g/m_nDivision + m_nBias, 255);
b = min(b/m_nDivision + m_nBias, 255);
r = max(r, 0);
g = max(g, 0);
b = max(b, 0);
return RGB(r, g, b);
}
CUndoNode::CUndoNode(CDibImage* pImage, const CString& sDescription)
{
m_pImage = pImage;
m_sDescription = sDescription;
}
CUndoNode::~CUndoNode()
{
delete m_pImage;
m_pImage = NULL;
}
CDibImage::CDibImage()
{
m_hDib = NULL;
m_pWorkingArea = NULL;
m_nWidth = 0;
m_nHeight = 0;
m_nScanWidth = 0;
m_nBitsPerPixel = 0;
m_Pal = NULL;
m_nUndoSize = 4; //By default, we support 4 levels of undo, if you
//want more (at the expense of memory usage) just
//call SetUndoSize will the level you want
}
CDibImage::CDibImage(const CDibImage& ds)
{
m_hDib = NULL;
m_pWorkingArea = NULL;
m_nWidth = 0;
m_nHeight = 0;
m_nScanWidth = 0;
m_nBitsPerPixel = 0;
m_Pal = NULL;
m_nUndoSize = 4; //By default, we support 4 levels of undo, if you
//want more (at the expense of memory usage) just
//call SetUndoSize will the level you want
Attach((HDIB) CopyHandle(ds.m_hDib));
SetWorkingArea(ds.m_pWorkingArea->Clone());
}
CDibImage::~CDibImage()
{
Destroy();
//empty the redo stack
for (int i=0; i<m_RedoStack.GetSize(); i++)
{
CUndoNode* pNode = m_RedoStack.GetAt(i);
delete pNode;
pNode = NULL;
}
m_RedoStack.SetSize(0);
//empty the undo stack
for (i=0; i<m_UndoStack.GetSize(); i++)
{
CUndoNode* pNode = m_UndoStack.GetAt(i);
delete pNode;
pNode = NULL;
}
m_UndoStack.SetSize(0);
}
CDibImage& CDibImage::operator=(c
没有合适的资源?快使用搜索试试~ 我知道了~
full and color chance.rar_CHANCE
共48个文件
h:15个
cpp:15个
ico:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 36 浏览量
2022-09-22
16:14:27
上传
评论
收藏 211KB RAR 举报
温馨提示
里面有关全屏的知识和颜色的选择
资源详情
资源评论
资源推荐
收起资源包目录
full and color chance.rar (48个子文件)
www.pudn.com.txt 218B
full and color chance
app.cpp 5KB
Release
dibedit.exe 117KB
res
dropper.cur 326B
Toolbar.bmp 2KB
dibtest.rc2 399B
tools.bmp 478B
rectangle.cur 326B
magnify.cur 326B
type.ico 766B
new.ico 1KB
dibtest.ico 766B
Doc.cpp 20KB
View.cpp 11KB
Doc.h 3KB
histogram.cpp 5KB
CombineDlg.h 865B
NewImageDlg.cpp 1KB
UserFilterDlg.cpp 3KB
UserFilterDlg.h 550B
dibimage.cpp 54KB
ColorPalette.cpp 4KB
ChildFrm.cpp 705B
dibedit.rc 56KB
dibedit.dsw 537B
DIBAPI.H 2KB
dibimage.gif 478B
dibimage.h 8KB
histogram.h 776B
StdAfx.cpp 205B
NewImageDlg.h 553B
MYFILE.CPP 8KB
MainFrm.cpp 7KB
resource.h 14KB
dibedit.dsp 6KB
MainFrm.h 2KB
ChildFrm.h 421B
StdAfx.h 525B
dibimage.zip 111KB
CombineDlg.cpp 2KB
dibimage.htm 42KB
DIBAPI.CPP 14KB
OneValueDlg.h 1KB
OneValueDlg.cpp 2KB
dibedit.clw 18KB
View.h 2KB
colorpalette.h 527B
app.h 1KB
共 48 条
- 1
御道御小黑
- 粉丝: 61
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0