Author Topic: PascalMagick - magicklcl.LoadMagickBitmap(filename, tbitmap)  (Read 90 times)


  • Full Member
  • ***
  • Posts: 114
The wiki entry for PascalMagick suggests a unit magicklcl with procedures for loading a file or a stream of images into a TBitmap.

This unit is referenced as being proposed in this message thread ...,20016.msg114885.html#msg114885

The original posting was dealing with "Reading black & white TIFF images?"

I have tried following that in a simple project as suggested loading into a Timage.Picture.bitmap

However while the image loads with no errors, it is degraded appearing as bands of white and a lilac like colour.

The procedure I use was set to save the opened image to disk so it might be reviewed here.

I attach a reduced copy of the original jpeg (so it can fit in as a Forum attachment) and the output filename suffixed = with _rendered.
The output (Ive shrunk and produced as a PNG to preserve detail) does not look at all correct, in fact it seems to be monochrome in a lilac type colour,
and I remembered that the original procedure had been sparked in a discussion dealing with  monochrome tiffs.

What modifications should I make please, I can not see where to go with this at present.

Here is my simple routine relying on the Unit described and linked to above.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.opgetTrialImageClick(Sender: TObject);
  2.       begin
  3.   if OpenDialog1.Execute then
  4.    begin
  5.    magicklcl.LoadMagickBitmap(OpenDialog1.FileName, testImage.Picture.Bitmap);
  6.       testImage.Picture.SaveToFile(ExtractFileName(OpenDialog1.FileName)+'_rendered.jpg', 'jpg');
  7.    end;
  8. end;    

I also tried this totally in memory. That output filename is suffixed _rendered_virtually

Code: Pascal  [Select][+][-]
  1. procedure TForm1.openVirtualIMageClick(Sender: TObject);
  2. var
  3.   thisPicture : TPicture;
  4. begin
  5.      if OpenDialog1.Execute then
  6.    begin
  8.       thisPicture := TPicture.Create;
  10.         try
  11.              magicklcl.LoadMagickBitmap(OpenDialog1.FileName, thisPicture.Bitmap);
  12.                 thisPicture.SaveToFile(ExtractFileName(OpenDialog1.FileName)+'_rendered_virtually.jpg', 'jpg');
  13.         finally
  14.             thisPicture.Free;
  15.         end;
  17.    end;
  18. end;        

Both output images look the same. slightly posturized and monochrome.

Any advice appreciated please.
What am I missing, no doubt something very simple, here?

As I say, I've attached the output images here, but I had to shrink and process two of them to PNGs, and a smaller version of original jpeg, to fit them in a Forum posting, but the resultant problem can be clearly seen.



TinyPortal © 2005-2018