Forum > Graphics

fcl-image and TImage

(1/1)

adderthorn:
I am working with a library that creates bitmaps using the fcl-image classes, I am trying to integrate this into a GUI application and display these bitmaps, I can't seem to find a way to do this. I've tried doing this with a stream, but it fails on me. Any thoughts?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ABitmap:=LIBRARYCLASS.ToBitmapImage(1, 1);Writer:=TFPWriterBMP.Create;AStream:=TMemoryStream.Create;ABitmap.SaveToStream(AStream, Writer);Image1.Picture.Bitmap.LoadFromStream(AStream, 1);

wp:
Assuming that line 1 in your example is correct, then you simply can assign ABitmap to Image1.Picture:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Image1.Picture.Assign(ABitmap);
Your code with the stream should work, too. But you must be aware that the stream.Position is at the end after ABitmap.SaveToStream; therefore, there's nothing to read for Image1.Picture.Bitmap.LoadFromStream. Rewinding the stream should help:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---...ABitmap.SaveToStream(AStream, Writer);AStream.Position := 0;Image1.Picture.Bitmap.LoadFromStream(AStream, 1);

adderthorn:
Thank-you! This was what I needed. Still having an issue (now getting Invalid palette index 0), but I think this is the library I'm using, so I'm doing some more debugging.

Navigation

[0] Message Index

Go to full version