Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Größe in TImage (https://www.delphipraxis.net/166570-groesse-timage.html)

danten 19. Feb 2012 13:18

Größe in TImage
 
Liste der Anhänge anzeigen (Anzahl: 1)
Bitte entschuldigen Sie mein Deutsch.

Mám vytvořený PaintBox o rozměrech 800 x 600.
Zeichnen Sie das Bild, an dem sie bisher unbekannte Dimensionen.

Ich muss irgendwie bestimmen die minimale und maximale positionieren Sie den Cursor zum Zeitpunkt der Zeichnung, und dann automatisch zuschneiden nur den Teil, der gezeichnet wird.

Vielen Dank

haentschman 19. Feb 2012 13:28

AW: Größe in TImage
 
Hallo danten...

Willkommen, Welcome :dp:

Du kannst auch in Englisch schreiben. You also can write in English.

Sometimes it´s enough to use the Google translator. Please use always the same language.

:hi:

Questions:
- You want to know this Rect ?
- Paint you this Rect by yourself ?
- What you mean with positioning the Cursor ?

danten 19. Feb 2012 13:31

AW: Größe in TImage
 
Vielen Dank, aber ich bin aus der Tschechischen Republik und den Google-Übersetzer.
Thank you but I'm from Czech Republic and use the google translator.
:oops:

haentschman 19. Feb 2012 13:36

AW: Größe in TImage
 
I think the translation to english is better... :zwinker:

It´s not a Problem... we help you. What about the questions ?

DeddyH 19. Feb 2012 13:37

AW: Größe in TImage
 
I think you will have to scan the pixels of the canvas line by line (Canvas.Pixels or ScanLine can be used for this). Then you need to remember the first and the last occurence of a different color, on the X- and on the Y-axis. The resulting rect is limited by these 4 values.

Popov 19. Feb 2012 13:38

AW: Größe in TImage
 
Dann mal ahoj.

haentschman 19. Feb 2012 13:39

AW: Größe in TImage
 
Scanline is faster then Canvas.Pixels

danten 19. Feb 2012 13:40

AW: Größe in TImage
 
Ahoj :lol:

Creating a project in which the user can draw a picture to RichEdit.
The position of "Row" and "Count" is automatically created to the page Paintbox.
At this Paintbox user will draw. Once you finish drawing and clicks the "Enter", so I need to crop the image automatically and only the coordinates, where an image and discard the rest.
It is unnecessary to file a 100 x 100 pixel screen takes up the size as 800 x 600 pixels.

Trying to get coordinates Mouse_Min_Top, Mouse_Max_Top, Mouse_Min_Left, Mouse_Max_left.
Once I know these coordinates, the problem is not crop the image.

Please show a little code.
Thank you very much

haentschman 19. Feb 2012 13:46

AW: Größe in TImage
 
Zitat:

the problem is not crop the image.
...ok. Do you want to save the cutted Part to a File ? Which Format ?

danten 19. Feb 2012 13:48

AW: Größe in TImage
 
BMP please.

haentschman 19. Feb 2012 14:01

AW: Größe in TImage
 
you have to change... is an Idea but can be wrong :zwinker:
Delphi-Quellcode:
var aPicture:TBitmap;
    PictureName:string;
    aSourceRect:TRect;
   aDestinationRect;
begin
 aPicture:=TBitmap.Create;
 try
   aPicture.Width:=100; // your cutted Size
   aPicture.Height:=100; // your cutted Size
   aDestinationRect:= (0,0,100,100);
   aSourceRect:=Rect(100,200,200,300); // your cutted Rect
   aPicture.Canvas.CopyRect(aDestinationRect, YourPaintBox.Canvas, aSourceRect); // Copy the Rect from the Paintbox to the Image
   PictureName:= 'MyPicture'; // define the Name
   aPicture.SaveToFile('YourFolder\' + PictureName + '.bmp');
 finally
   aPicture.free;
 end

DeddyH 19. Feb 2012 14:07

AW: Größe in TImage
 
A short test:
Delphi-Quellcode:
procedure TFormTest.Button1Click(Sender: TObject);
var
  XIndex, YIndex, XMin, XMax, YMin, YMax: integer;
begin
  XMin := PaintBox1.ClientWidth;
  YMin := PaintBox1.ClientHeight;
  XMax := 0;
  YMax := 0;
  for YIndex := 0 to PaintBox1.ClientHeight - 1 do
    for XIndex := 0 to PaintBox1.ClientWidth - 1 do
      if PaintBox1.Canvas.Pixels[XIndex, YIndex] <>
        PaintBox1.Canvas.Brush.Color then
        begin
          if XIndex < XMin then
            XMin := XIndex;
          if YIndex < YMin then
            YMin := YIndex;
          if XIndex > XMax then
            XMax := XIndex;
          if YIndex > YMax then
            YMax := YIndex;
        end;
  PaintBox1.Canvas.Brush.Style := bsClear;
  PaintBox1.Canvas.Pen.Color := clBlue;
  PaintBox1.Canvas.Rectangle(XMin - 1, YMin - 1, XMax + 2, YMax + 2);
end;
As said before: Canvas.Pixels is quite slow, ScanLine is much faster, but you have to do some work yourself ;)

haentschman 19. Feb 2012 14:14

AW: Größe in TImage
 
@DeddyH: Er hat den Ausschnitt, weiß nur nicht wie er ihn rauskriegt und in eine Datei ablegt... denke ich mal 8-)

DeddyH 19. Feb 2012 14:16

AW: Größe in TImage
 
Dann lies #8 nochmal genau durch ;)

haentschman 19. Feb 2012 14:19

AW: Größe in TImage
 
ok... ich habe das "once" überlesen :oops: Aber mit beiden kann er was anfangen...

danten 19. Feb 2012 15:08

AW: Größe in TImage
 
I'm sorry, but I do not understand.
Where can I get the position Min_Top, Max_Top, Min_Left, Max_Left?

The presented examples only draws me around the entire frame Paintbox and nothing else.

We could use a Record?

DeddyH 19. Feb 2012 15:13

AW: Größe in TImage
 
Your Min_Top is my YMin and so on. Maybe the comparison in my example does not fit, you should check this.

danten 19. Feb 2012 15:38

AW: Größe in TImage
 
I love programming in Delphi and you are also friends.

The procedure was correct, but it wants to communicate with Paintbox, but only in the Image.

A special thank you "DeddyH"
:thumb:

DeddyH 19. Feb 2012 15:40

AW: Größe in TImage
 
No problem :)

haentschman 19. Feb 2012 15:52

AW: Größe in TImage
 
:thumb:
Please change your Delphi Version in your Profile...

danten 19. Feb 2012 16:12

AW: Größe in TImage
 
Zitat:

Zitat von haentschman (Beitrag 1151876)
:thumb:
Please change your Delphi Version in your Profile...

Already completed is the profile :lol::roll:

haentschman 19. Feb 2012 16:36

AW: Größe in TImage
 
Perfekt... 8-)

Prag... i want too... for Holiday :cry:


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:44 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz