기본 콘텐츠로 건너뛰기

C++ - Gray Color 정보 가져오기 (PNG -> Binary)

void __fastcall TDataModule_Vision::SetGrayColorInfo_PNG(TPngImage* img, double r, double g, double b)
{
RGBTRIPLE *rtColor;

delete m_GrayColor;
int size = m_Height * m_Width;
m_GrayColor = new double[size];
memset(m_GrayColor, 0, sizeof(double) * size);

for(int y = 0; y < m_Height; y++)
{
//rtColor=(RGBTRIPLE*)img->Picture->Bitmap->ScanLine[y + m_Y];    // 세로에서 읽어
        rtColor = (RGBTRIPLE*)img->Scanline[y + m_Y];
for(int x = 0; x < m_Width; x++)
{
m_GrayColor[(x * m_Height) + y] =
((double)rtColor[x + m_X].rgbtRed * r)
+((double)rtColor[x + m_X].rgbtGreen * g)
+((double)rtColor[x + m_X].rgbtBlue * b);
}
}
}

댓글