🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.borland-delphi
Article #644

Re: Canvas.Point Problems...

#644
From: Robert Rossmair
Date: Fri, 07 Jan 2000 00:00
64 lines
3132 bytes
Note: Follow-up to borland.public.delphi.graphics set.

Hi Michael,

I tried to understand your posting, but lacked success.  Could you
please post the complete code of the procedures mentioned?

> The Set Method uses the TBitmap.Create; method to create the DestImage:
> DestImage := TBitmap.Create;

Hopefully you don't create a memory leak here.

> So I am adding the addTemplate method. This takes a file name of a bitmap
> file that is one pixel wider than the DestImage bitmap.
> 
> I read out the bottom right corner's colour:
> theColour := Template.Canvas.Point(maxx, maxy);

What are the values of maxx, maxy? They should be

  maxx = Template.Width-1;
  maxy = Template.Heigth-1;
 
> theColour is a Tcolor, and seems to get set fine. Template is another
> TBitmap, and loads from the file.
> 
> Then I do:
> For x:=0 to 54 do begin
>   For y:=0 to 22 do begin
>     If Template.Canvas.Point(x,y) <> theColour then
>      DestImage.Canvas.Point(x,y) := Template.Canvas.Point(x,y);
>   end;
> end;
> 
> i.e. trying to step through each point, copying it if it is not that
> bitmap's transparent colour.

This seems to be a very crude and inefficient way to do that task.

if you are working with Delphi version 3 or above, try:

  with Template do
    TransparentColor := Canvas.Pixels[Width-1, Height-1];
  DestImage.Canvas.Draw(0, 0, Template);

Note that the assignment to Template.TransparentColor could be omitted
if you'd store the transparency information in the last row of pixels
instead of the last column.

> Only nothing seems to change on the DestImage when it is saved out. I have
> tried a DestImage.Canvas.FillRect(10,10,20,20); and that doesn't seem to
> change it either.
> 
> Stepping through that method IS reached and executed and the bitmap IS
> saved.

IMHO nothing can be said concerning the reason for this behavior without
additional information.

Greetings, Robert
-- 
Robert Ro�mair
http://home.t-online.de/home/Robert.Rossmair/
Programming environment: Delphi 5 Professional, WinNT 4.0 SP6
Technical Details
Message-ID: <38760F7C.E5C125D6@t-online.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3871bc45.0@news.myratech.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: fd817,761ad309370abca6
X-Google-Attributes: gidfd817,public
X-Google-Thread: 10a296,761ad309370abca6
X-Google-Attributes: gid10a296,public
X-Google-Thread: f894d,761ad309370abca6
X-Google-Attributes: gidf894d,public
X-Google-Thread: 105ac8,761ad309370abca6
X-Google-Attributes: gid105ac8,public
From: Robert Rossmair <Robert.Rossmair@t-online.de>
Subject: Re: Canvas.Point Problems...
Date: 2000/01/07
Message-ID: <38760F7C.E5C125D6@t-online.de>
X-Deja-AN: 569595977
Content-Transfer-Encoding: 8bit
References: <3871bc45.0@news.myratech.net>
X-Accept-Language: de,en
X-Sender: 340065752685-0001@t-dialin.net
Followup-To: borland.public.delphi.graphics
Content-Type: text/plain; charset=iso-8859-1
X-Complaints-To: abuse@t-online.de
X-Trace: news00.btx.dtag.de 947262883 9144 340065752685-0001 000107 16:34:43
Organization: -
Mime-Version: 1.0
Newsgroups: alt.comp.borland-delphi,alt.comp.lang.borland-delphi,borland.public.delphi,borland.public.delphi.graphics