本文整理汇总了C++中ImpressionistDoc::GetOriginalPixel方法的典型用法代码示例。如果您正苦于以下问题:C++ ImpressionistDoc::GetOriginalPixel方法的具体用法?C++ ImpressionistDoc::GetOriginalPixel怎么用?C++ ImpressionistDoc::GetOriginalPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImpressionistDoc
的用法示例。
在下文中一共展示了ImpressionistDoc::GetOriginalPixel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetColor
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample
// the color from
//----------------------------------------------------
void ImpBrush::SetColor (const Point source, int optional_alpha)
{
ImpressionistDoc* pDoc = GetDocument();
GLubyte color[4];
memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
color[3] = static_cast<GLubyte>(255.0f * m_pDoc->getAlpha());
// dirty patch
// just bear it, this is life
// for debug
/*
int tset = optional_alpha;
char msg[222];
sprintf(msg, "%d\n\n", tset);
OutputDebugString(msg);
*/
if (optional_alpha > 0) {
// OutputDebugString("called, gengge\n");
color[3] = (GLubyte)optional_alpha;
}
for (int i = 0; i < 3; i++) {
if (m_pDoc->m_pUI->m_ReverseColorButton->value()) color[i] = (GLubyte) (255 - color[i] * m_pDoc->m_pUI->blendColor[i]);
else color[i] = (GLubyte) (color[i] * m_pDoc->m_pUI->blendColor[i]);
}
glColor4ubv( color );
}
示例2: SetColor
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample
// the color from
//----------------------------------------------------
void ImpBrush::SetColor (const Point source)
{
ImpressionistDoc* pDoc = GetDocument();
GLubyte color[4];
memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
color[3] = (GLubyte)pDoc->getAlpha(); //Set the alpha channel to whatever the slider says
glColor4ubv( color );
}
示例3: SetColor
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample
// the color from
//----------------------------------------------------
void ImpBrush::SetColor (const Point source)
{
ImpressionistDoc* pDoc = GetDocument();
GLubyte color[3];
memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
glColor3ubv( color );
}
示例4: SetColor
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample
// the color from
//----------------------------------------------------
void ImpBrush::SetColor(const Point source, float alphaValue) // alphaValue from 0 - 1
{
ImpressionistDoc* pDoc = GetDocument();
GLubyte color[4];
memcpy(color, pDoc->GetOriginalPixel(source), 3);
color[3] = (GLubyte)(alphaValue * 255.0f);
for (int i = 0; i < 3; i++)
color[i] = (GLubyte)(color[i] * m_pDoc->m_pUI->getBlendColour(i));
glColor4ubv(color);
}
示例5: SetColor
void GreyscaleBrush::SetColor (const Point source)
{
ImpressionistDoc* pDoc = GetDocument();
GLubyte color[3];
memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
// Convert the color to a greyscale
float brightness = 2.0;
float gray = (color[0]/255.0*0.299 + color[1]/255.0*0.587 + color[2]/255.0*0.114)/3.0 * brightness;
gray = (gray > 1.0) ? 1.0 : gray;
glColor3f( gray, gray, gray );
}
示例6: SetColor
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample
// the color from
//----------------------------------------------------
void ImpBrush::SetColor (const Point source)
{
ImpressionistDoc* pDoc = GetDocument();
float alpha = pDoc->getAlpha();
float* colorBlend = pDoc->getColorBlend();
GLubyte color[4];
memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
color[0] = static_cast<GLubyte> (color[0] * colorBlend[0]);
color[1] = static_cast<GLubyte> (color[1] * colorBlend[1]);
color[2] = static_cast<GLubyte> (color[2] * colorBlend[2]);
color[3] = static_cast<GLubyte>(alpha * 255.f);
glColor4ubv( color );
}
示例7: Blur
void FilterBrush::Blur(const Point source, double opacity){
ImpressionistDoc* pDoc = GetDocument();
GLubyte color[3][3][3];
GLubyte filteredColor[4];
for (int i = -1; i < 2; i++)
for (int j = -1; j < 2;j++)
memcpy(color[i+1][j+1], pDoc->GetOriginalPixel(Point(source.x+i,source.y+j)), 3);
for (int k = 0; k < 3; k++){
filteredColor[k] = (1 * (color[0][0][k] + color[0][2][k] + color[2][0][k] + color[2][2][k]) \
+ 2 * (color[0][1][k] + color[1][0][k] + color[1][2][k] + color[2][1][k]) + 4 * color[1][1][k])/16;
}
filteredColor[3] = opacity * 255;
glColor4ubv(filteredColor);
}
示例8: SetColorOpac
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample
// the color from
//----------------------------------------------------
void ImpBrush::SetColorOpac(const Point source, double opacity)
{
ImpressionistDoc* pDoc = GetDocument();
float r = pDoc->m_pUI->m_colorChooser->r();
float g = pDoc->m_pUI->m_colorChooser->g();
float b = pDoc->m_pUI->m_colorChooser->b();
GLubyte color[4];
memcpy(color, pDoc->GetOriginalPixel(source), 3);
color[0] *= r;
color[1] *= g;
color[2] *= b;
color[3] = opacity * 255;
//glColor3ubv(color);
glColor4ubv(color);
}
示例9: Sharpen
void FilterBrush::Sharpen(const Point source, double opacity){
ImpressionistDoc* pDoc = GetDocument();
GLubyte color[3][3][3];
GLubyte filteredColor[4] = { 0, 0, 0, 0 };
for (int i = -1; i < 2; i++)
for (int j = -1; j < 2; j++)
memcpy(color[i + 1][j + 1], pDoc->GetOriginalPixel(Point(source.x + i, source.y + j)), 3);
//for (int k = 0; k < 3; k++){
// filteredColor[k] =(-1 * (color[0][1][k] + color[1][0][k] + color[1][2][k] + color[2][1][k]) + 4 * color[1][1][k]);
//}
int kernel[3][3] = { -1, -1, -1, -1, 8, -1, -1, -1, -1 };
int kCenterX = 1;
int kCenterY = 1;
int ii, jj, mm, nn;
for (int k = 0; k < 3; k++){
for (int m = 0; m < 3; m++) // kernel rows
{
mm = 2 - m; // row index of flipped kernel
for (int n = 0; n < 3; n++) // kernel columns
{
nn = 2 - n; // column index of flipped kernel
// index of input signal, used for checking boundary
ii = m;
jj = n;
filteredColor[k] = filteredColor[k] + (color[ii][jj][k] * kernel[mm][nn]);
}
}
}
filteredColor[3] = opacity * 255;
glColor4ubv(filteredColor);
}
示例10: SetColor
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample
// the color from
//----------------------------------------------------
void ImpBrush::SetColor (const ImpBrush::Point source)
{
ImpressionistDoc* pDoc = GetDocument();
GLfloat alpha = pDoc->getAlpha();
GLubyte color[3];
memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
//
// Setup the alpha settings
//
GLfloat color_r = ((GLfloat)color[0]/255);
GLfloat color_g = ((GLfloat)color[1]/255);
GLfloat color_b = ((GLfloat)color[2]/255);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(color_r, color_g, color_b, alpha);
}
示例11: SetColor
//----------------------------------------------------
// Set the color to paint with to the color at source,
// which is the coord at the original window to sample
// the color from
//----------------------------------------------------
void ImpBrush::SetColor (const Point source)
{
ImpressionistDoc* pDoc = GetDocument();
int r, g, b;
ucolor32 col = pDoc->getBlendColor();
GLubyte color[4];
memcpy ( color, pDoc->GetOriginalPixel( source ), 3 );
// Blend the color
UNPACK_COLOR(r, g, b, col);
color[0] = (unsigned)((r * color[0]) / 255);
color[1] = (unsigned)((g * color[1]) / 255);
color[2] = (unsigned)((b * color[2]) / 255);
//Alpha
color[3] = (int)(pDoc->getAlpha() * 255);
glColor4ubv( color );
}
示例12: BrushMove
void ScatteredLineBrush::BrushMove(const Point source, const Point target)
{
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg = pDoc->m_pUI;
if (pDoc == NULL) {
printf("LineBrush::BrushMove document is NULL\n");
return;
}
int size = pDoc->getSize();
int angle = pDoc->getAngle();
double opacity = pDoc->getOpac();
int strokeDirChoice = dlg->m_StrokeDirChoice->value();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
srand(time(0));
glMatrixMode(GL_MODELVIEW);
switch (strokeDirChoice){
// Slider/Right mouse
case 0:
// don't have to change size and angle value
for (int i = 0; i < 4; i++){
float length = fRand(1, size / 2)*2.5;
float dist = fRand(-size*0.3, size*0.3)*2.5;
float displacement = fRand(-size*0.75, size*0.75);
float x1 = target.x + displacement;
float y1 = target.y + dist;
glPushMatrix();
glTranslatef(x1, y1, 0.0);
glRotatef(angle, 0.0, 0.0, 1.0);
glTranslatef(-x1, -y1, 0.0);
glBegin(GL_LINE_STRIP);
SetColorOpac(Point(source.x + displacement, source.y + dist), opacity);
glVertex2d(x1 - length*0.75, y1);
glVertex2d(x1 + length*0.75, y1);
glEnd();
glPopMatrix();
}
break;
// Gradient
case 1:
// change angle value according to
// the gradient at this point
for (int i = 0; i < 4; i++){
float length = fRand(1, size / 2)*2.5;
float dist = fRand(-size*0.3, size*0.3)*2.5;
float displacement = fRand(-size*0.75, size*0.75);
float x1 = target.x + displacement;
float y1 = target.y + dist;
double Gx;
double Gy;
GLubyte color[3][3][3];
double intensity[3][3];
for (int i = -1; i < 2; i++){
for (int j = -1; j < 2; j++){
memcpy(color[i + 1][j + 1], pDoc->GetOriginalPixel(Point(source.x + displacement + i, source.y + dist + j)), 3);
intensity[i + 1][j + 1] = 0.299*color[i + 1][j + 1][0] + 0.587*color[i + 1][j + 1][1] + 0.144*color[i + 1][j + 1][2];
}
}
Gx = intensity[0][0] * (-1) + intensity[0][1] * (-2) + intensity[0][2] * (-1)\
+ intensity[2][0] * (1) + intensity[2][1] * (2) + intensity[2][2] * (1);
Gy = intensity[0][0] * (-1) + intensity[1][0] * (-2) + intensity[2][0] * (-1)\
+ intensity[0][2] * (1) + intensity[1][2] * (2) + intensity[2][2] * (1);
angle = -(int)(atan2(Gy, Gx)*57.32) % 360;
glPushMatrix();
glTranslatef(x1, y1, 0.0);
glRotatef(angle, 0.0, 0.0, 1.0);
glTranslatef(-x1, -y1, 0.0);
glBegin(GL_LINE_STRIP);
SetColorOpac(Point(source.x + displacement, source.y + dist), opacity);
glVertex2d(x1 - length*0.75, y1);
glVertex2d(x1 + length*0.75, y1);
glEnd();
glPopMatrix();
}
break;
// Brush direction
case 2:
current.x = target.x;
current.y = target.y;
if (prev.x!=-1&¤t.x!=-1&&(current.x != prev.x || current.y != prev.y)){
int dx = current.x - prev.x;
int dy = current.y - prev.y;
angle = (int)(atan2(dy, dx)*57.32) % 360;
for (int i = 0; i < 4; i++){
float length = size;
float dist = fRand(-size*0.3, size*0.3)*2.5;
float displacement = fRand(-size*0.75, size*0.75);
float x1 = target.x + displacement;
//.........这里部分代码省略.........
示例13: SobelGradient
GLint ScatteredLinesBrush::SobelGradient(const ImpBrush::Point source)
{
/*
a0 a1 a2
a7 a3
a6 a5 a4
*/
ImpressionistDoc *pDocument = GetDocument();
GLubyte dColor[3];
GLdouble fAtan = 0.0;
GLint dAngle = 0.0;
ImpBrush::Point srcPoint = source;
GLdouble a0, a1, a2, a3, a4, a5, a6, a7;
// Calculate a0 above ..
srcPoint.x = source.x-1;
srcPoint.y = source.y+1;
memcpy(dColor, pDocument->GetOriginalPixel(srcPoint),3);
a0 = GraphicsUtils::GetLuminosity(dColor);
// Calculate a1 above ..
srcPoint.x = source.x;
srcPoint.y = source.y+1;
memcpy(dColor, pDocument->GetOriginalPixel(srcPoint), 3);
a1 = GraphicsUtils::GetLuminosity(dColor);
// Calculate a2 above ..
srcPoint.x = source.x + 1;
srcPoint.y = source.y + 1;
memcpy(dColor, pDocument->GetOriginalPixel(srcPoint), 3);
a2 = GraphicsUtils::GetLuminosity(dColor);
// Calculate a3 above ..
srcPoint.x = source.x + 1;
srcPoint.y = source.y;
memcpy(dColor, pDocument->GetOriginalPixel(srcPoint), 3);
a3 = GraphicsUtils::GetLuminosity(dColor);
// Calculate a4 above ..
srcPoint.x = source.x + 1;
srcPoint.y = source.y - 1;
memcpy(dColor, pDocument->GetOriginalPixel(srcPoint), 3);
a4 = GraphicsUtils::GetLuminosity(dColor);
// Calculate a5 above ..
srcPoint.x = source.x + 1;
srcPoint.y = source.y - 1;
memcpy(dColor, pDocument->GetOriginalPixel(srcPoint), 3);
a5 = GraphicsUtils::GetLuminosity(dColor);
// Calculate a6 above ..
srcPoint.x = source.x - 1;
srcPoint.y = source.y - 1;
memcpy(dColor, pDocument->GetOriginalPixel(srcPoint), 3);
a6 = GraphicsUtils::GetLuminosity(dColor);
// Calculate a7 above ..
srcPoint.x = source.x - 1;
srcPoint.y = source.y;
memcpy(dColor, pDocument->GetOriginalPixel(srcPoint), 3);
a7 = GraphicsUtils::GetLuminosity(dColor);
/*
Sobel Filter is - the following two matrices convolved
with the image. fdY & fdX
[-1 0 1]
[-2 0(x,y) 2]
[-1 0 1]
[1 2 1]
[0 0(x,y) 0]
[-1 -2 -1]
We'll average the gradient at the center pixel
*/
// Multiply with a the matrix above
GLdouble fDx = (a2 + 2 * a3 + a4) - (a0 + 2 * a7 + a6);
GLdouble fDy = (a0 + 2 * a1 + a2) - (a6 + 2 * a5 + a4);
fAtan = atan2(fDy, fDx);
// Switch to Radians
dAngle = fAtan * (180 / PI);
// Account for negative angles ..
dAngle = (dAngle < 0) ? (360 + dAngle) : dAngle;
// We want the line to be drawn 90 degress
// perpendicular to the gradient change.
dAngle = (GLint)(dAngle + 90);
dAngle %= 360;
return dAngle;
}
示例14: SetColor
void MotionBlurBrush::SetColor(const Point source) {
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg = pDoc->m_pUI;
GLdouble MotionBlur[81] =
{
1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1,
};
GLfloat red = 0.0;
GLfloat green = 0.0;
GLfloat blue = 0.0;
int index = 0;
GLubyte tempColor[3];
GLubyte color[3];
GLfloat color1[3];
GLfloat tempColor1[3];
for (int k = -4; k <= 4; k += 1) {
for (int l = -4; l <= 4; l += 1) {
memcpy(tempColor, pDoc->GetOriginalPixel(source.x + k, source.y + l), 3);
// We strictly need to convert to float!!!
// I spent a lot of time finding the solution
for (int n = 0; n < 3; n++)
{
tempColor1[n] = (float)tempColor[n];
}
red += tempColor1[0] * MotionBlur[index];
green += tempColor1[1] * MotionBlur[index];
blue += tempColor1[2] * MotionBlur[index];
++index;
}
}
double factor = 1.0 / 9.0;
double bias = 0.0;
red = min(max(int(factor * red + bias), 0), 255);
green = min(max(int(factor * green + bias), 0), 255);
blue = min(max(int(factor * blue + bias), 0), 255);
color1[0] = red;
color1[1] = green;
color1[2] = blue;
// Change to GLubyte before setting color to brush
color[0] = (GLubyte)color1[0];
color[1] = (GLubyte)color1[1];
color[2] = (GLubyte)color1[2];
glColor3ubv(color);
}
示例15: SetColor
void EmbossBrush::SetColor(const Point source) {
ImpressionistDoc* pDoc = GetDocument();
ImpressionistUI* dlg = pDoc->m_pUI;
//// 3x3 kernel
//GLdouble WeightedMeanKernel[9] =
//{ 1 / 9, 1 / 9, 1 / 9,
//1 / 9, 1 / 9, 1 / 9,
//1 / 9, 1 / 9, 1 / 9,
//};
//GLdouble GaussianKernel[9] =
//{ 0.0625, 0.125, 0.0625,
// 0.125, 0.25, 0.125,
// 0.0625, 0.125, 0.0625,
//};
GLfloat red = 0.0;
GLfloat green = 0.0;
GLfloat blue = 0.0;
int index = 0;
GLubyte tempColor[3];
GLubyte color[3];
GLfloat color1[3];
GLfloat tempColor1[3];
GLfloat EmbossKernel[25] =
{ -1, -1, -1, -1, 0,
-1, -1, -1, 0, 1,
-1, -1, 0, 1, 1,
-1, 0, 1, 1, 1,
0, 1, 1, 1, 1
};
for (int k = -2; k <= 2; k += 1) {
for (int l = -2; l <= 2; l += 1) {
memcpy(tempColor, pDoc->GetOriginalPixel(source.x + k, source.y + l), 3);
// We strictly need to convert to float!!!
// I spent a lot of time finding the solution
for (int n = 0; n < 3; n++)
{
tempColor1[n] = (float)tempColor[n];
}
red += tempColor1[0] * EmbossKernel[index];
green += tempColor1[1] * EmbossKernel[index];
blue += tempColor1[2] * EmbossKernel[index];
++index;
}
}
double factor = 1.0;
double bias = 128.0;
red = min(max(int(factor * red + bias), 0), 255);
green = min(max(int(factor * green + bias), 0), 255);
blue = min(max(int(factor * blue + bias), 0), 255);
color1[0] = red;
color1[1] = green;
color1[2] = blue;
// Change to GLubyte before setting color to brush
color[0] = (GLubyte)color1[0];
color[1] = (GLubyte)color1[1];
color[2] = (GLubyte)color1[2];
glColor3ubv(color);
}