Autor Beitrag
Freiberger
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

WIN XP
Delphi 7
BeitragVerfasst: Mo 30.10.06 10:27 
Hallo,

ich habe mehrere TImages mit Icons versehen.
Form1.Image1.Picture.Icon.LoadFrofile...

Kann mir jemand verraten, wie ich jetzt die Farbe unter der Maus auslesen kann ?
Wenn ich eine .bmp lade ( Form1.Image1.Picture.Bitmap.LoadFromFile ), dann kann ich die Farbe über Scanline oder Canvas.Pixels[x,y] auslesen.

Warum geht das bei Icons nicht ???
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: Mo 30.10.06 11:10 
es müsste aber mit Canvas.Pixels[x,y] gehen. du musst halt Form1.Canvas nehmen und X,Y der Maus auf der Form ( Mouse.CursorPos.X-Form.Left/Mouse.CursorPos.Y-Form.Top)

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)
Freiberger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

WIN XP
Delphi 7
BeitragVerfasst: Mo 30.10.06 11:33 
habe es noch nicht probiert, aber da bekomme ich Probleme, wenn ich andere Bilder unter dem Icon anzeige.
Ich möchte eigentlich nur wissen, ob die Farbe unter der Maus die transparente Farbe ist (also ob ich wirklich auf dem richtigen Bild bin...)
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: Mo 30.10.06 12:04 
hmm, das ist allerdings ein Problem :gruebel:

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)
Freiberger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

WIN XP
Delphi 7
BeitragVerfasst: Mo 30.10.06 12:15 
oder gibt es noch eine Andere Möglichkeit ?
Ich will (wie z.B. im MediaPlayer) eine Grafig als Hintergrund nehmen.
Darauf sollen Icons (oder Bitmaps) als Buttons.
Bie Bitmaps ist nur die Transparenz nicht so gut, da sie Ränder so verpixelt sind.
Icons passen sich der Hintergrund-Farbe an.

Jetzt soll aber geprüftt werden, ob die Maus auch wirklich über dem Bild ist, und nich im transparenten Bereich, also über dem Hintergrund...
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: Mo 30.10.06 12:30 
user profile iconFreiberger hat folgendes geschrieben:

Jetzt soll aber geprüftt werden, ob die Maus auch wirklich über dem Bild ist, und nich im transparenten Bereich, also über dem Hintergrund...


1. das is normalerweise nie so, dass man durch das Icon "durchklicken" kann
2. du müsstest gucken, ob die Farbe auf die du geklickt hast = der Hintergrundfarbe ist. (Wenn die z.B. schwarz ist, dann mach sie ganz ganz dunkelgrau oder so, dann hast du einen bestimmten Wert, der dann ziemlich sicher nur der Hintergrund hat.)

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)
Freiberger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

WIN XP
Delphi 7
BeitragVerfasst: Mo 30.10.06 12:33 
Aber ich kann doch das Hintergrundbild nich ganz Dinkelgrau machen ?
Kann man BMPs nich so umwandeln, dass sie auch so transparent wie ICONs sind ?
Saubäär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 376



BeitragVerfasst: Mo 30.10.06 13:25 
Versuchs mal mit PNG's. Die kannst transparent machen und sie sind auch nicht so verpixelt.
Die Frage ist nur, ob sie in Delphi auch transparent dargestellt werden? - Aber ich denke schon!

Gruß

Saubäär
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: Mo 30.10.06 13:26 
ich glaub man kann in D7 gar keine png in ein Image laden.

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)
Freiberger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

WIN XP
Delphi 7
BeitragVerfasst: Mo 30.10.06 13:27 
OK, versuche ich mal.
Aber wie mache ich aus den ICONs oder aus BMPs
PNGs ?
Mit vieles Programmen kann ich zwar PNGs speichern, aber dann werden die Ränder verpixelt...
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 30.10.06 13:42 
Hallo,

user profile iconFreiberger hat folgendes geschrieben:
...
Ich möchte eigentlich nur wissen,
...
(also ob ich wirklich auf dem richtigen Bild bin...)

kannst Du das den nicht über die Koordinaten der Images herausfinden?

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Freiberger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130

WIN XP
Delphi 7
BeitragVerfasst: Mo 30.10.06 13:57 
wie meinst du das, über die Koordinaten ???
Hier ist mal ne simple Grafik, wie es aussehen könnte.
Das Problem ist nur, die Bilder überlagern sich im Transparenten Bereich...
Einloggen, um Attachments anzusehen!
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Di 31.10.06 11:34 
Hallo,

hmmm, aus dem Anhang kann ich nicht sehr viel Infos entnehmen.

bzgl. der Koordinaten >>
Man kann doch feststellen über welchem Image sich die Maus befindet. Wenn man dann den Ansatz von user profile iconXion (Canvas der Form) berücksichtigt, die Koordinaten der Maus in Koordinaten der Form umrechnet, dann hat man die Farbe unter der Maus des jeweils im Image geladenen Icons.

Im folgenden Beispiel habe ich die Ereignisbehandlungsmethode MyImageMouseMove im OI beiden TImages zugewiesen.

Eventuell hilft Dir der Code weiter.
Hier mal die komplette Unit:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Image2: TImage;
    Button1: TButton;
    procedure MyImageMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
implementation

{$R *.DFM}

procedure TForm1.MyImageMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var aPoint : TPoint;
begin
  aPoint := Point(X,Y);
  //Image-Koordinaten in Form-Koordinaten umrechnen
  aPoint  := TImage(Sender).ClientToScreen(ScreenToClient(aPoint));
  Caption := TImage(Sender).Name+'      '
             +IntToStr(Canvas.Pixels[aPoint.X,aPoint.Y]);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  Bitmap : TBitMap;
begin                                     
  Image1.Left := 50;
  Image1.Top := 50;
  Image2.Left := 60;
  Image2.Top := 60;
  Bitmap := TBitmap.Create;
  try
    Bitmap.LoadFromFile('C:\temp\Orchidee.bmp');
    Canvas.Draw(0,0,Bitmap);
  finally
    Bitmap.Free;
  end;
  Image1.Picture.Icon.LoadFromFile('C:\temp\google.ico');
  Image2.Picture.Icon.LoadFromFile('C:\temp\gmx.ico');
end;

end.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )