• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 
11 February 2026, 19:27:04

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - mos

16
Thank you very much, your solution work great under Linux and under Windows  :)


Bye
17
I'm trying to draw a line on an instance of TImage,  I have wrote this code with Lazarus 0.9.25:


procedure TForm1.FormCreate(Sender: TObject);
begin
  Form1.Color := clBlack;

  FImage1 := TSingleImage.Create;
  FBitmap1 := TImagingBitmap.Create;
  Image1.Picture.Graphic := FBitmap1;
  FImage1.LoadFromFile('Tigers.jpg');
  Image1.Picture.Graphic.Assign(FImage1);
 
  Image1.Picture.Bitmap.Canvas.Pen.Color := clWhite;
  Image1.Picture.Bitmap.Canvas.Line(0, 0, 200, 200);
end;


where Image TImage type on Form1 of TForm.

This code work ok on Linux (Fedora), I see a white line, but on Windows (WinXP) I see a black line.
If I set "Form1.Color := clRed;" on Windows I see a red line, in Linux is always ok, I see a white line.

In conclusion, in Windows the line color is the same of the Form color, Why?

Can you help me?


Goodbye
18
I have added your code (on WinXP+SP2 with Lazarus 0.9.24 and on other partition with Lazarus 0.9.25), but I have always a black area with white line:


  Image2.Transparent := True;
 
  FImage1 := TMultiImage.Create;
  FBitmap1 := TImagingBitmap.Create;
  Image1.Picture.Graphic := FBitmap1;

  FImage1.LoadMultiFromFile('e:\Tigers.jpg'); // my background image
  Image1.Picture.Graphic.Assign(FImage1);

  FImage2 := TMultiImage.Create;
  FBitmap2 := TImagingBitmap.Create;
  FBitmap2.Width:=449;
  FBitmap2.Height:=303;
  Image2.Picture.Graphic := FBitmap2;
  FImage2.LoadMultiFromFile('e:\black.bmp'); // my foreground image, a black bitmap of same dimension of background image
  Image2.Picture.Graphic.Assign(FImage2);

  Image2.Canvas.Brush.Color := clBlack;
  Image2.Canvas.FillRect(Image2.ClientRect);
  Image2.Canvas.Pen.Color := clWhite;
  Image2.Canvas.Line(0, 0, 200, 200);
19
Really? This is strange. You have try under WinXP?

I have set to True the Transparent property of Image2 in the IDE, and now also in the code but what I see is always a Image1 with the background image and Image2 with a black image and the line that I draw is transparent.

I have attached a screenshot of the window, also I have attached the source code (here naturally you must change the Paths in Compiler Options).


Bye
20
I want 2 Image (Image1, Image2) of TImage type, one (Image2, foreground) overlaying the other (Image1, background).
The Image1 must contain a Jpeg image, the Image2 must be a transparent (on clBlack color) bitmap over the user can draw lines.

I have write the following code, but this not work, what I obtain is a black image over a background image, but where the white line I draw is transparent!
Instead what I want is a white line over background image.

Can you help me?


Thanks



source code:

unit Unit1;

{$I ImagingOptions.inc}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  StdCtrls,
  ImagingTypes,
  Imaging,
  ImagingClasses,
  ImagingComponents,
  ImagingCanvases,
  ImagingUtility;

type

  { TForm1 }

  TForm1 = class(TForm)
    Image1: TImage;
    Image2: TImage;

  private
    { private declarations }
  public
    { public declarations }
    FBitmap1: TImagingBitmap;
    FImage1: TMultiImage;
   
    FBitmap2: TImagingBitmap;
    FImage2: TMultiImage;

  end;

var
  Form1: TForm1;

implementation

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
  FImage1 := TMultiImage.Create;
  FBitmap1 := TImagingBitmap.Create;
  Image1.Picture.Graphic := FBitmap1;
 
  FImage1.LoadMultiFromFile('e:\background.jpg'); // my background image
  Image1.Picture.Graphic.Assign(FImage1);
 
  FImage2 := TMultiImage.Create;
  FBitmap2 := TImagingBitmap.Create;

  Image2.Picture.Graphic := FBitmap2;
  FImage2.LoadMultiFromFile('e:\foreground.bmp'); // my foreground image, a black bitmap of same dimension of background image

  Image2.Picture.Graphic.Assign(FImage2);
  Image2.Picture.Bitmap.Transparent := True;
  Image2.Picture.Bitmap.TransparentColor := clBlack;

  Image2.Canvas.Pen.Color := clWhite;
  Image2.Canvas.Line(0, 0, 200, 200);

end;

initialization
  {$I Unit1.lrs}

end.


21
For this last error I have resolved on this way (see red lines):

[...cut...]
{$IFDEF COMPONENT_SET_LCL}
  // Get raw image from bitmap (mask handle must be 0 or expect violations)
  { If you get complitation error here upgrade to Lazarus 0.9.24+ }
  aRect := Classes.Rect(0, 0, Data.Width, Data.Height);
  if RawImage_FromBitmap(RawImage, Bitmap.Handle, 0, @aRect) then

  begin
    LineLazBytes := GetBytesPerLine(Data.Width, RawImage.Description.BitsPerPixel,
      RawImage.Description.LineEnd);
[...cut...]

with aRect of TRect type, now I compile with success.

There's a better solution?


Bye

22
Thankyou for your answer, I have fixed it, but I have another error:

E:\SVILUPPO\Imaging\Source\ImagingComponents.pas(728,97) Error: Incompatible type for arg no. 4: Got "RECT", expected "PRect"

Source code of ImagingComponents.pas line 728 (red line):

[...cut...]
{$IFDEF COMPONENT_SET_LCL}
  // Get raw image from bitmap (mask handle must be 0 or expect violations)
  { If you get complitation error here upgrade to Lazarus 0.9.24+ }
  if RawImage_FromBitmap(RawImage, Bitmap.Handle, 0, Classes.Rect(0, 0, Data.Width, Data.Height)) then
  begin
    LineLazBytes := GetBytesPerLine(Data.Width, RawImage.Description.BitsPerPixel,
      RawImage.Description.LineEnd);
[...cut...]

Can you help me on this?


Bye


23
I compile the demo project \Imaging\Demos\ObjectPascal\LCLImager with Lazarus 0.9.25 under WinXPSP2 but I obtain the following error:

E:\SVILUPPO\Imaging\Source\ImagingComponents.pas(117,14) Error: There is no method in an ancestor class to be overridden: "TImagingGraphicForSave.GetDefaultMimeType:AnsiString"

Can you help me?


Goodbye & thanks
SMF spam blocked by CleanTalk