ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Help ! ImageEnMView on ImageEnView
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Boban

Yugoslavia
41 Posts

Posted - Nov 05 2012 :  20:51:54  Show Profile  Reply
Hi

What should I change in this code to add or to obtain a left vertikal and top border as shown on the right and bottom ?
----------------------------------------------------------------------
var
i:integer;
x, y:integer;
bmp:TIEBitmap;
begin

ImageEnView1.IEBitmap.Allocate(ImageEnMView1.ClientWidth + MaximumViewX, Form2.Image1.ClientHeight + MaximumViewY);
x := ImageEnMView1.CalcGridWidth() * (ImageEnMView1.ThumbWidth + ImageEnMView1.HorizBorder);
y := ImageEnMView1.CalcGridHeight() * (ImageEnMView1.ThumbHeight + ImageEnMView1.VertBorder);
ImageEnView1.Proc.ImageResize(x, y);
ImageEnView1.Proc.Fill(ColorDialog1.Color);

x := 0;
y := 0;
for i:=0 to ImageEnMView1.ImageCount-1 do
begin
bmp := ImageEnMView1.GetTIEBitmap(i);
bmp.RenderToTIEBitmapEx(Form2.Image1.IEBitmap, x, y, ImageEnMView1.ThumbWidth, ImageEnMView1.ThumbHeight, 0, 0, bmp.Width, bmp.Height, 255, rfTriangle);
ImageEnMView1.ReleaseBitmap(i);
inc(x, ImageEnMView1.ThumbWidth + ImageEnMView1.HorizBorder);
if x > ImageEnView1.IEBitmap.Width - ImageEnMView1.ThumbWidth then
begin
x := 0;
inc(y, ImageEnMView1.ThumbHeight + ImageEnMView1.VertBorder);
if y > ImageEnView1.IEBitmap.Height then
break;
end;
end;

ImageEnView1.Update;
end;
===========================================================================================


xequte

39064 Posts

Posted - Nov 06 2012 :  01:31:12  Show Profile  Reply
Hi

From a quick review of your code i don't see anything particularly wrong with it. What problem do you get with it?



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

Boban

Yugoslavia
41 Posts

Posted - Nov 06 2012 :  04:41:42  Show Profile  Reply
Hi

I miss the left vertical edge and the upper edge of the horizontal orange as it is one the right and on the bottom of the picture.
Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 06 2012 :  07:01:59  Show Profile  Reply

39.66 KB
var
  i: integer;
  x, y: integer;
  bmp: TIEBitmap;
begin
  Screen.Cursor := crHourGlass;
  try
    ImageEnView1.Clear;
    x := ImageEnMView1.CalcGridWidth() * (ImageEnMView1.ThumbWidth + ImageEnMView1.HorizBorder);
    y := ImageEnMView1.CalcGridHeight() * (ImageEnMView1.ThumbHeight + ImageEnMView1.VertBorder);
    ImageEnView1.IEBitmap.Allocate(x + 5, y + 5);
    ImageEnView1.Proc.Fill(clBlack);
    x := 0;
    y := 0;
    for i := 0 to ImageEnMView1.ImageCount - 1 do
    begin
      bmp := ImageEnMView1.GetTIEBitmap(i);
      bmp.RenderToTIEBitmapEx(ImageEnView1.IEBitmap, x+5 , y+5 , ImageEnMView1.ThumbWidth- 5,
        ImageEnMView1.ThumbHeight - 5, 10, 10, bmp.Width-5, bmp.Height-5, 255, rfTriangle);
      ImageEnMView1.ReleaseBitmap(i);
      inc(x, ImageEnMView1.ThumbWidth + ImageEnMView1.HorizBorder);
      if x > ImageEnView1.IEBitmap.Width - ImageEnMView1.ThumbWidth then
      begin
        x := 0;
        inc(y, ImageEnMView1.ThumbHeight + ImageEnMView1.VertBorder);
        if y > ImageEnView1.IEBitmap.Height then
          break;
      end;
    end;
    ImageEnView1.Update;
  finally
    Screen.Cursor := crDefault;
end;

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

Boban

Yugoslavia
41 Posts

Posted - Nov 07 2012 :  18:35:23  Show Profile  Reply
Hi William

It's okay but it works in my program i have set for vertikal and horizontal adjustement between the frames so that when you set the vertikal and horizontal spacing, then the left and right edges remains the same unchanged always the same width. Is this in the above code can be changed by setting the vertical and horizontal spacing automatically changes the left and upper edges to be the same as that between the frames? Thank you in advance.

Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 08 2012 :  18:16:15  Show Profile  Reply
I do not understand what you are trying to describe.

The spaceing between all the cells is the same here.

Here is a method to draw the grid where you can set the spacing:
procedure CreateThumbnailGrid(var AImageEnMView: TImageEnMView; AImageEnView: TImageEnView; ASpacing: integer);
var
  i: Integer;
  iIEBitmap: TIEBitmap;
  x: Integer;
  y: Integer;
begin
  Screen.Cursor := crHourGlass;
  try
    AImageEnView.Clear;
    x := AImageEnMView.CalcGridWidth * (AImageEnMView.ThumbWidth + AImageEnMView.HorizBorder);
    y := AImageEnMView.CalcGridHeight * (AImageEnMView.ThumbHeight + AImageEnMView.VertBorder);
    AImageEnView.IEBitmap.Allocate(x + ASpacing, y + ASpacing);
    AImageEnView.Proc.Fill(clBlack);
    x := 0;
    y := 0;
    for i := 0 to AImageEnMView.ImageCount - 1 do
    begin
      iIEBitmap := AImageEnMView.GetTIEBitmap(i);
      iIEBitmap.RenderToTIEBitmapEx(AImageEnView.IEBitmap, x + ASpacing, y + ASpacing,
        AImageEnMView.ThumbWidth - ASpacing, AImageEnMView.ThumbHeight - ASpacing, 10, 10,
        iIEBitmap.Width - ASpacing, iIEBitmap.Height - ASpacing, 255, rfTriangle);
      AImageEnMView.ReleaseBitmap(i);
      inc(x, AImageEnMView.ThumbWidth + AImageEnMView.HorizBorder);
      if x > AImageEnView.IEBitmap.Width - AImageEnMView.ThumbWidth then
      begin
        x := 0;
        inc(y, AImageEnMView.ThumbHeight + AImageEnMView.VertBorder);
        if y > AImageEnView.IEBitmap.Height then
          break;
      end;
    end;
    AImageEnView.Update;
  finally
    Screen.Cursor := crDefault;
  end;
end;


To use it:
procedure TForm1.ThumbnailGrid1Click(Sender: TObject);
// Create a grid of thumbnails
var
  iSpacing: integer;
  sSpacing: string;
begin
  sSpacing := InputBox('Spacing', 'Enter Grid Spacing', '5');
  iSpacing := StrToIntDef(sSpacing, 5);
  CreateThumbnailGrid(ImageEnMView1, ImageEnView1, iSpacing);
end;


39.65 KB Spacing = 5


38.76 KB Spacing = 10

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

Boban

Yugoslavia
41 Posts

Posted - Nov 12 2012 :  11:46:42  Show Profile  Reply
Thank you William
That's what I needed.

But again I was stuck when placing text from (Memo component) I got this look like the figure below the bottom of the picture is cropped. To the extent that the above is added to the text so the image cut down. Where now I made a mistake in this code?




procedure CreateThumbnailGrid(var ImageEnMView1: TImageEnMView; Image1: TImageEnView; ColorDialog1: TColorDialog; Memo1: TMemo; ASpacing: integer);
var
h, i: Integer;
iIEBitmap: TIEBitmap;
x: Integer;
y: Integer;
begin
Screen.Cursor := crHourGlass;
try
ImageEnView1.Clear;

x := ImageEnMView1.CalcGridWidth * (ImageEnMView1.ThumbWidth + ImageEnMView1.HorizBorder);
y := ImageEnMView1.CalcGridHeight * (ImageEnMView1.ThumbHeight + ImageEnMView1.VertBorder);
ImageEnView1.IEBitmap.Allocate(x + ASpacing, y + ASpacing);

ImageEnView1.Proc.Fill(ColorDialog1.Color);

x := 0;
y := Memo1.ClientHeight - ASpacing;

// Memo1
ImageEnView1.IEBitmap.Canvas.Font := Memo1.Font;
h := ImageEnView1.IEBitmap.Canvas.TextHeight('Test');
for i := 0 to Memo1.Lines.Count - 1 do
ImageEnView1.IEBitmap.Canvas.TextOut(3, i * h, Memo1.Lines[i]);

for i := 0 to ImageEnMView1.ImageCount - 1 do
begin
iIEBitmap := ImageEnMView1.GetTIEBitmap(i);
iIEBitmap.RenderToTIEBitmapEx(ImageEnView1.IEBitmap, x + ASpacing, y + ASpacing,
ImageEnMView1.ThumbWidth - ASpacing, ImageEnMView1.ThumbHeight - ASpacing, 0, 0,
iIEBitmap.Width - ASpacing, iIEBitmap.Height - ASpacing, 255, rfTriangle);
ImageEnMView1.ReleaseBitmap(i);
inc(x, ImageEnMView1.ThumbWidth + ImageEnMView1.HorizBorder);
if x > ImageEnView1.IEBitmap.Width - ImageEnMView1.ThumbWidth then
begin
x := 0;
inc(y, ImageEnMView1.ThumbHeight + ImageEnMView1.VertBorder);
if y > ImageEnView1.IEBitmap.Height + Memo1.ClientHeight then
break;
end;
end;

ImageEnView1.Update;
finally
Screen.Cursor := crDefault;
end;
end;
Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 12 2012 :  17:57:08  Show Profile  Reply
You have to expand the height of the bitmap by the height of the text here:
ImageEnView1.IEBitmap.Allocate(x + 5, y + 55); // just a guess


William Miller
Go to Top of Page

Boban

Yugoslavia
41 Posts

Posted - Nov 12 2012 :  19:15:34  Show Profile  Reply
Thank you William

How can I add a SoftShadow on the thumbnails to ImageEnView CheckBox component ?

Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 13 2012 :  08:25:12  Show Profile  Reply
Thre is no such thing as a ImageEn checkbox component.

William Miller
Go to Top of Page

Boban

Yugoslavia
41 Posts

Posted - Nov 13 2012 :  09:35:55  Show Profile  Reply
Hi William

I thought we CheckBox component is only an option for setting the shadow of ImageEnMView thumbnails ImageEnView. Or it does not have the ImageEnMView. Whether it be in this code to do that option or something else? Greetings.

procedure CreateThumbnailGrid(var ImageEnMView1: TImageEnMView; Image1: TImageEnView; ColorDialog1: TColorDialog; Memo1: TMemo; ASpacing: integer);
var
h, i: Integer;
iIEBitmap: TIEBitmap;
x: Integer;
y: Integer;
begin
Screen.Cursor := crHourGlass;
try
Form2.Image1.Clear;

x := ImageEnMView1.CalcGridWidth * (ImageEnMView1.ThumbWidth + ImageEnMView1.HorizBorder);
y := ImageEnMView1.CalcGridHeight * (ImageEnMView1.ThumbHeight + ImageEnMView1.VertBorder);
Form2.Image1.IEBitmap.Allocate(x + ASpacing, y + 60);

Form2.Image1.Proc.Fill(ColorDialog1.Color);

x := 0;
y := Memo1.ClientHeight - ASpacing;

// Memo1
Form2.Image1.IEBitmap.Canvas.Font := Memo1.Font;
h := Form2.Image1.IEBitmap.Canvas.TextHeight('Test');
for i := 0 to Memo1.Lines.Count - 1 do
Form2.Image1.IEBitmap.Canvas.TextOut(x+ASpacing, i * h, Memo1.Lines[i]);

for i := 0 to ImageEnMView1.ImageCount - 1 do
begin
iIEBitmap := ImageEnMView1.GetTIEBitmap(i);
iIEBitmap.RenderToTIEBitmapEx(Form2.Image1.IEBitmap, x + ASpacing, y + ASpacing,
ImageEnMView1.ThumbWidth - ASpacing, ImageEnMView1.ThumbHeight - ASpacing, 0, 0,
iIEBitmap.Width - ASpacing, iIEBitmap.Height - ASpacing, 255, rfTriangle);
ImageEnMView1.ReleaseBitmap(i);
inc(x, ImageEnMView1.ThumbWidth + ImageEnMView1.HorizBorder);
if x > Form2.Image1.IEBitmap.Width - ImageEnMView1.ThumbWidth then
begin
x := 0;
inc(y, ImageEnMView1.ThumbHeight + ImageEnMView1.VertBorder);
if y > Form2.Image1.IEBitmap.Height + Memo1.ClientHeight then
break;
end;
end;
Form2.Show;
Form2.Image1.Update;
finally
Screen.Cursor := crDefault;
end;
end;
------------------------------------------------------------------
Here's looking from another program.

Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 13 2012 :  11:16:13  Show Profile  Reply
You are calling RenderToTIEBitmapEx so there is no way to add a softshadow to each thumbnail. You would have to apply a AImageEnView.Proc.AddSoftShadow(5, 4, 4, True) to each thumbnail then draw each thumbnail on a canvas.

So you would have to extract each bitmap from ImageEnView, create a thumbnail of specified dimensions, apply a softwhadow to the thumbnail, then draw each thumbnail in a canvas with spacing large enough so the shadow is visible.

Some along the lines of: (UNTESTED CODE)
x := ImageEnMView1.CalcGridWidth * (ImageEnMView1.ThumbWidth +   ImageEnMView1.HorizBorder);
  y := ImageEnMView1.CalcGridHeight * (ImageEnMView1.ThumbHeight + ImageEnMView1.VertBorder);
 // Create the main image bitmap
 Form2.Image1.IEBitmap.Allocate(x + ASpacing, y + 60);
 Form2.Image1.Proc.Fill(ColorDialog1.Color);
// get each image and process it
for i := 0 to ImageEnMView1.ImageCount-1 do
begin
  // Get the image from imageenview
  iBitmap := ImageEnMView1.GetBitmap[i];
  ImageEnView.ReleaseBitmap;
  // Create an ImageEnProc component
  iImageEnProc := TImageEnProc.Create(nil);
  // Set the attached bitmap
  iImageEnProc.AttachedIEBitmap := iBitmap;
  // Resamplethe bitmap to create a thumbnail
  iImangeEnProc.Proc.Resample();
  // add a softshadow to the bitmap
  iImangeEnProc.AddSoftShadow(5, 4, 4, True);
  // Draw each shadowed thumbnail on the base bitmap canvas
  Form2.Image1.IEBitmap.Canvas.Draw();
end;
 iImageEnProc.Free;
 Form2.Image1.Update;
end;

William Miller
Go to Top of Page

Boban

Yugoslavia
41 Posts

Posted - Nov 14 2012 :  00:58:31  Show Profile  Reply
Hi William

I tried this in my error logs. I tried to correct, but I failed.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: