c++ 기본적인 질문좀 드리겠습니다 ㅠ

odaesu의 이미지

학교에서 visual c++ 6.0 으로 수업을 하는데요 ㅠㅠ

이미지를 불러와서 히스토그램 그래프를 만들고
이미지들간의 히스토그램 그래프의 차를 구해서
이미지의 유사성을 구하는 프로그램을 만드는건데요

거두절미하고

void CImageProView::OnDraw(CDC* pDC)
{
CImageProDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int x, y;
for (y=0; y<256; y++)
{
for (x=0; x<256; x++)
{
pDC ->SetPixel(x,y,RGB(pDoc->inputImg[y][x], pDoc->inputImg[y][x], pDoc->inputImg[y][x]));
}
}
for (y=0; y<256; y++)
{
for (x=0; x<256; x++)
{
pDC ->SetPixel(x+300,y,RGB(pDoc->resultImg[y][x], pDoc->resultImg[y][x], pDoc->resultImg[y][x]));
}
}
}

위 코드처럼 이미지를 그리는 것은되는데 간단한 변수안의 데이터 값을 출력하는 방법을 모르겠습니다 ㅠㅠ
예를들면 inputImg[5][5]배열의 값을 숫자로 출력하려면 C같은경우 printf("%d",inputImg[5][5]);로 처리하면 되지만
CDC에서는 도대체 어떻게 하는지 모르겠습니다

P.s pDC-> TextOut(x, y, inputImg[5][5])로 해본결과 Ascii code가 출력되는 것같은데 혹시나 Ascii code >> 10진수로 출력하는 방법이라도 아시는분 계신가요

yukariko의 이미지

이걸 물어보시지는 않을것 같습니다만..

printf("%c",'3');

ASCII CODE값이 어떻게 나와있는지 자세하게 알려주셔야 정확한 답변을 얻어가실 수 있을겁니다.

odaesu의 이미지

밑에 보시면 왼쪽이 불러온 이미지이고 { 가 inputImg[15][15]값에 해당하는 아스키 코드 같습니다.

댓글 첨부 파일: 
첨부파일 크기
Image icon example.jpg79.26 KB
yukariko의 이미지

CString str;
str.Format("%d",inputImg[15][15]);
pDC->TextOut(x, y, str);
이런걸 말씀하시는건가요?

odaesu의 이미지

정말 감사드립니다 하루종일 고생했는데 ㅠㅠㅠ 여기 고수님들이 많으시네요!!

익명 사용자의 이미지

TextOut으로 문자열을 원하는 위치에 출력하시는 데까진 성공하신거 같은데
숫자값이 들어간 문자열을 만드는걸 어떻게 하는지 모르겠다는 질문이죠?
그러면 그 다음은 간단하죠.

sprintf 쓰세요.
printf와 비슷한데 대신 문자열에다가 출력해주는 함수입니다.
그럼 그걸 TextOut으로 넘겨주면 되죠

char buf[1024];
int len;

len = sprintf(buf, "Num : %d", int_val);
TextOut(hdc, x, y, buf, len);

뭐 대충 저런 식으로 쓰시면 됩니다.

사실 WinAPI에선 StringCbPrintf를 쓰는게 더 바람직하긴 한데...
편하신 쪽으로 사용하세요.

odaesu의 이미지

감사감사합니다 확인은못해봤지만 답변 감사드립니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.