TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: KNUT SCHUENEMANN
date: 1997-10-14 16:33:00
subject: C++Builder-Frage: TCanvas, Pixel!

>>> I've got two questions about the code below:
#include 
#pragma hdrstop
#include "GTest.h"
#include "GTestChild.h"
#pragma resource "*.dfm"
TGraphtest *Graphtest;
//---------------------------------------------------------------------------
void __fastcall TGraphtest::SpeedButton1Click(TObject *Sender)
{
Canvas->Pen->Mode = pmBlack;
Canvas->MoveTo(1,1);
Canvas->LineTo(640,400);
Canvas->MoveTo(1,400);
Canvas->MoveTo(640,1);
}
>>> Shouldn't this function draw a black cross at the Screen or at the form?
//---------------------------------------------------------------------------
void __fastcall TGraphtest::LoadBitmapClick(TObject *Sender)
{
int x, y;
TColor Color;
Graphics::TBitmap *Bmp;
if (OpenDialog->Execute())
 {
  Bmp = new Graphics::TBitmap;
  Image->Picture->LoadFromFile(OpenDialog->FileName);
  Bmp->Assign(Image->Picture->Bitmap);
  TChild* child = new TChild(this);
  child->Image->Picture->Assign(Bmp);
  child->ClientWidth = Bmp->Width;
  child->ClientHeight = Bmp->Height;
  child->Caption = OpenDialog->FileName;
  // Syntax-Test:
  x = (int)((Bmp->Width)/2);
  y = (int)((Bmp->Height)/2);
  Color = child->Canvas->Pixels[x][y];
  child->Caption = (0x00FFFFFF & Color);
  Color = ((0x00FFFFFF & Color) > 0x00800000)? 0x00000000 : 0x00FFFFFF;
  child->Canvas->Pen->Mode = pmCopy;
  child->Canvas->Pen->Color = Color;
  child->Canvas->Pen->Width = 1;
  child->Canvas->Pen->Style = psDot;
  child->Canvas->MoveTo(x-10, y-10);
  child->Canvas->LineTo(x+10, y+10);
  child->Canvas->MoveTo(x-10, y+10);
  child->Canvas->LineTo(x+10, y-10);
  }
}
>>> This function loads an image and display it in an own window, but why
>>> dosn't it draw a small cross in the center of the image in a visible
>>> color?
Knut
--- Yuppie v2.11
---------------
* Origin: The Stoned Ghost (2:2437/120.5)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.