Problem with crop image with fix W/H

Please discuss general Delphi programming topics here.

Problem with crop image with fix W/H

Postby lgrfbs » September 11th, 2011, 2:19 pm

Delphi 3
Form1 = main program
JPEGImage1: TJPEGImage; //Handel the jpeg image.
ScrollBox1: TScrollBox; // handel big jpeg image.
OpenDialog1: TOpenDialog; //Dialog for load the jpeg file.
PopupMenu1: TPopupMenu; //popup menu
SaveImage: TMenuItem;
LoadImage: TMenuItem;
Avsluta: TMenuItem; //Exit program


Form2 = Preview windows
Image1:Timage

This code in the Unit1.pas at procedure TForm1.JPEGImage1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
Code: Select all
 
For addX:=1 to 95 do
 Begin
  For addY:=1 to 67 do
  Begin
   Form2.Image1.Canvas.Pixels[addX, addY] := Form1.JPEGImage1.Canvas.Pixels[ziX+addX,ziY+addY];
  End;
 End;

This programcode works but not as good I want it to, what can I do for a better code?
Attachments
Unit2.pas
(397 Bytes) Downloaded 216 times
Unit1.pas
(3.53 KiB) Downloaded 171 times
lgrfbs
Member
Member
 
Posts: 3
Joined: September 11th, 2011, 1:58 pm

Re: Problem with crop image with fix W/H

Postby Kambiz » September 11th, 2011, 8:07 pm

Convert your JPEG image to bitmap (by assigning it to a bitmap), then use CopyRect method of canvas to crop the image.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: Problem with crop image with fix W/H

Postby lgrfbs » September 14th, 2011, 5:53 am

I will try it soon.
The "JPEGImage1" is a component as load jpeg file and is based on the timage, shall I remove this and draw direct on a cavans insted?
lgrfbs
Member
Member
 
Posts: 3
Joined: September 11th, 2011, 1:58 pm

Re: Problem with crop image with fix W/H

Postby Kambiz » September 14th, 2011, 7:50 am

If you draw the image on canvas, it would be easier for you to use CopyRect method.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: Problem with crop image with fix W/H

Postby lgrfbs » September 25th, 2011, 10:03 pm

Sorry for the late answer, I are in professional training for my real work.
I have try to do as you say, the new is in the zip file.

The is 3 things I want to fix:
* Then I move the mouse over the big images and the crop preview window do real update.
* The output crop images shall be in 256 colour and bmp-format.
* Remove the for-code in the procedure TForm1.JPEGImage1Click(Sender: TObject); for the preview window.

I can not write graphics code in delphi as good I want.
Attachments
A.zip
2011-09-25: Some new code.
(790.33 KiB) Downloaded 299 times
lgrfbs
Member
Member
 
Posts: 3
Joined: September 11th, 2011, 1:58 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron