Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determining which image was clicked on.
Message
De
27/03/2003 12:57:38
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
27/03/2003 11:58:01
Todd Cottengim
Alpine Land Information Services
Redding, Californie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Divers
Thread ID:
00770803
Message ID:
00770858
Vues:
10
>I am creating an application that displays a number of images as a mosaic. The images displayed are GIFs with white as the transparency color. The image controls overlap each other since the non-white area of the images displayed are irregular shapes.
>
>A simplified example would be this:
>A form contains four image controls of the same size (height and width) occupying the same location (same top and left). Four GIFs of the same size (also the same size as the image control) are created as follows: The first is solid red in the upper left quarter of the image with the rest being white (transparent). The second is blue in the upper right, the third green in the lower left, and the fourth is yellow in the lower right.
>
>I would like to be able to determine if the corrdinate pair (x,y) I have clicked at is a white pixel or not. I plan on adding a method (call it CheckColor) to the image control that will detwermine the color of the coordinates passed to it. A second method on the image control would be called if the corrdinate pair is not white. A method on a shape covering all the images would process each image's CheckColor until one returns a possitive result or all the iamge control have been checked.
>
>BTW: The Point() method on the form will not suffice.
>
>Any suggestions?
>
>Todd Cottengim
>Alpine Land Information Services

Maybe this helps :
_Screen.Visible = .F.
oForm = Createobject('MyForm')
oForm.Show
Read Events
_Screen.Visible = .T.

Define Class myForm As Form
  Top = 0
  Left = 0
  Height = 97
  Width = 233
  ShowWindow = 2
  DoCreate = .T.
  BorderStyle = 0
  Caption = "Mouse Pos and Color"
  posx = 0
  posy = 0
  pixelcolor = 0
  Name = "Form1"

  Add Object lblxpos As Label With ;
    Caption = "XPos", ;
    Height = 17, ;
    Left = 13, ;
    Top = 15, ;
    Width = 31, ;
    Name = "lblXpos"

  Add Object lblypos As Label With ;
    Caption = "Ypos", ;
    Height = 17, ;
    Left = 14, ;
    Top = 45, ;
    Width = 30, ;
    Name = "lblYpos"

  Add Object lblcolor As Label With ;
    Caption = "Color", ;
    Height = 17, ;
    Left = 12, ;
    Top = 75, ;
    Width = 32, ;
    Name = "lblColor"

  Add Object txtxpos As TextBox With ;
    FontBold = .T., ;
    ControlSource = "thisform.PosX", ;
    Height = 23, ;
    Left = 52, ;
    ReadOnly = .T., ;
    Top = 12, ;
    Width = 100, ;
    Name = "txtXpos"

  Add Object txtypos As TextBox With ;
    FontBold = .T., ;
    ControlSource = "Thisform.PosY", ;
    Height = 23, ;
    Left = 52, ;
    ReadOnly = .T., ;
    Top = 42, ;
    Width = 100, ;
    Name = "txtYpos"

  Add Object txtcolor As TextBox With ;
    FontBold = .T., ;
    ControlSource = "Thisform.PixelColor", ;
    Height = 23, ;
    Left = 52, ;
    ReadOnly = .T., ;
    Top = 72, ;
    Width = 100, ;
    Name = "txtColor"

  Add Object timer1 As Timer With ;
    Top = 0, ;
    Left = 156, ;
    Height = 23, ;
    Width = 23, ;
    Interval = 100, ;
    Name = "Timer1"

  Add Object colorshower As Container With ;
    Top = 33, ;
    Left = 167, ;
    Width = 49, ;
    Height = 49, ;
    Name = "ColorShower"

  Procedure Load
  Declare Sleep In Win32API Integer
  Declare short GetCursorPos In win32api String @ lpPoint
  Declare Integer GetWindowDC In Win32API Integer HWnd
  Declare Integer GetPixel In win32API ;
    integer hdc, Integer nXPos, Integer nYPos
Endproc

  Procedure QueryUnload
  Clear Events
Endproc

  Procedure timer1.Timer
  lpPoint = Space(8)
  With Thisform
    If GetCursorPos(@lpPoint)#0
      .posx = Asc(Substr(lpPoint,1))*256^0+;
        asc(Substr(lpPoint,2))*256^1+;
        asc(Substr(lpPoint,3))*256^2+;
        asc(Substr(lpPoint,4))*256^3
      .posy = Asc(Substr(lpPoint,5))*256^0+;
        asc(Substr(lpPoint,6))*256^1+;
        asc(Substr(lpPoint,7))*256^2+;
        asc(Substr(lpPoint,8))*256^3
      .pixelcolor = GetPixel(GetWindowDC(0), .posx, .posy)
      .colorshower.BackColor = .pixelcolor
      .Refresh()
    Endif
  Endwith
Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform