C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[19738] Re:Re:Re:한 줄씩 그리는 이미지 작성 어떻게 하지요?
유영인.Chris [cuperido] 920 읽음    2002-07-02 14:22
동욱님이 넘 정확하게 설명해 주셔서 할 말은 없구요.. 이전에 ScanLine에 관해서 답변 올린적이 있었는데, 그 소스를 조금 변경해서 하시려는 작업에 맞춰 보았습니다.


//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{

#define WIDTH        300
#define HEIGHT       300

int               PIXEL[300][300];
int               itX, itY;
RGBTRIPLE         *rtColor;
Graphics::TBitmap *BITMAP = new Graphics::TBitmap;


// 임의 Pixels 지정. 바탕색은 하얀색, 그리고 빨간색 대각선 선 하나만 그림
FillMemory(PIXEL, sizeof(PIXEL), 0x00FFFFFF);
for(itX = 0; itX < WIDTH; itX ++)
     PIXEL[itX][itX] = clMaroon;


// 비트맵 설정
BITMAP->PixelFormat = pf24bit;
BITMAP->Width       = WIDTH;
BITMAP->Height      = HEIGHT;


// ScanLine 포인터를 받아 값을 바꾼다
for(itY = 0; itY < HEIGHT; itY ++) {
    rtColor = (RGBTRIPLE *)BITMAP->ScanLine[itY];

    for(itX = 0; itX < WIDTH; itX ++) {
      rtColor[itX].rgbtBlue  = (PIXEL[itX][itY] >> 16) & 0xFF;
      rtColor[itX].rgbtGreen = (PIXEL[itX][itY] >> 8)  & 0xFF;
      rtColor[itX].rgbtRed   = (PIXEL[itX][itY])       & 0xFF;
    }
}


Canvas->Draw(50, 50, BITMAP);
delete BITMAP;

}
//---------------------------------------------------------------------------



빌더매니아 님이 쓰신 글 :
: void __fastcall TForm1::Button1Click(TObject *Sender)
:
: {
:   Graphics::TBitmap *pBitmap = new Graphics::TBitmap();
: // This example shows drawing directly to the Bitmap
:   Byte *ptr;
:   try
:   {
:     pBitmap->LoadFromFile("C:\\Program Files\\Common Files\\Borland Shared\\Images\\Splash\\256color\\factory.bmp ");
:     for (int y = 0; y < pBitmap->Height; y++)
:     {
:       ptr = (Byte *)pBitmap->ScanLine[y];
:       for (int x = 0; x < pBitmap->Width; x++)
:
:         ptr[x] = (Byte)y;
:     }
:     Canvas->Draw(0,0,pBitmap);
:   }
:   catch (...)
:   {
:     ShowMessage("Could not load or alter bitmap");
:   }
:   delete pBitmap;
: }
:
: 그런데요..
: 위의 코드 "ScanLine"에 대한 example code인데요,
: (Byte *)pBitmap->ScanLine[y]; 에서 (Byte *)로 캐스팅을 하쟎아요?
: 그러면 ScanLine 메소드가 먹히질 않아요.
: 혹시 이유를 아시면 좀 가르쳐주실 수 있을까요?
:

+ -

관련 글 리스트
19690 한 줄씩 그리는 이미지 작성 어떻게 하지요? 빌더매니아 799 2002/06/28
30126     Re:한 줄씩 그리는 이미지 작성 어떻게 하지요? 이웅희 808 2002/06/29
19699     Re:한 줄씩 그리는 이미지 작성 어떻게 하지요? 김동욱 1033 2002/06/29
19705         Re:Re:한 줄씩 그리는 이미지 작성 어떻게 하지요? 빌더매니아 913 2002/06/29
19769             Re:Re:Re:한 줄씩 그리는 이미지 작성 어떻게 하지요? 빌더매니아 780 2002/07/03
19738             Re:Re:Re:한 줄씩 그리는 이미지 작성 어떻게 하지요? 유영인.Chris 920 2002/07/02
19733             Re:Re:Re:한 줄씩 그리는 이미지 작성 어떻게 하지요? 김동욱 831 2002/07/02
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.