<div dir="ltr">Of course the second part should have been Rect(0, 0, p.Jpeg.Width, p.Jpeg.Height)? :-P<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 10, 2017 at 7:01 PM, Kostas Michalopoulos <span dir="ltr"><<a href="mailto:badsectoracula@gmail.com" target="_blank">badsectoracula@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>You can check yourself easily: Ctrl+Click on the p.Width to go to the definition of the property, then Ctrl+Click on the GetWidth getter, Ctrl+Shift+Down arrow to see the code for the getter and see that it simply gets FGraphic's property. So what is FGraphic? Ctrl+Home to move at the top of the source code (you'd be in picture.inc) and search for "FGraphic :=" to see where it is assigned (the source code style in that file seems to put a space before := in assignments). You can see that it is used in a bunch of places, so you can see where those uses are. ForceType is the first one and if you search for that one, you'll find that it is used wherever a type-specific property (p.Jpeg, p.Bitmap, etc) is used - presumably to convert the underlying graphic to the requested type. So the FGraphic object is actually an instance of the TBitmap, TPortableNetworkGraphic, TJpegImage, etc (depending what you loaded and/or accessed last).<br><br></div><div>So what p.Width gives you is the FGraphic's width or 0 if there is no FGraphic loaded (because a picture may have nothing loaded until you either load it directly or try to access any of the Bitmap, Jpeg, PNG, etc properties). So if you already have a picture loaded from a PNG file, p.Width, p.Graphic.Width and p.PNG.Width will give you the same number. If your picture doesn't have a graphic (e.g. it is a newly constructed object) then p.Width gives you 0, p.Graphic.Width will crash your program (FGraphic is nil) and p.PNG.Width will give you zero (because accessing the PNG property will call the ForceType function which will create a TPortableNetworkGraphic object that by default is undefined and gives you zero width).<br><br></div><div>Question for the readers: what happens to the image if you load a PNG file with alpha values using TPicture's LoadFromFile, access the TPicture.Jpeg.Width property and then save the picture as a PNG file using TPicture's SaveToFile? Is the alpha component preserved? Do you get jpeg artifacts? Why?<br></div><div><br></div><div>Bonus question: why is R := Rect(0, 0, p.Jpeg.Width, p.PNG.Height) worse than R := Rect(0, 0, p.Jpeg.Width, p.PNG.Height)? Why is R := Rect(0, 0, p.Width, p.Height) better than either of them?<br><br></div><div>You can find the answers to those (and many more) using Ctrl+Click, Ctrl+Shift+Up/Down Arrow, Search and back and forward buttons (helps to have a mouse with those). Considering how big and complex LCL is, it helps to be able to navigate and familiarize yourself with its source code :-).<br></div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 9, 2017 at 7:44 PM, Lars via Lazarus <span dir="ltr"><<a href="mailto:lazarus@lists.lazarus-ide.org" target="_blank">lazarus@lists.lazarus-ide.org</a><wbr>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 2017-03-09 10:48, José Mejuto via Lazarus wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
AFAIK:<br>
<br>
TPicture.Width is the TGraphic container size.<br>
TPicture.jpeg.Width is the width declared in the jpeg image.<br>
TPicture.Bitmap.Width is the width of the bitmap in pixels.<br>
<br>
Mostly the 3 will have the same value but extracted from different sources.<br>
<br>
</blockquote>
<br></span>
If I start off using a bitmap, and all of a sudden start using jpeg, will it automagically work or does one have to initiate the jpeg in some way?<br>
<br>
Example: you start off working with a classic BMP, but then 60 lines of code later you want to work with it as a jpeg. Do you just magically start working with a jpeg without any worry, or you have to take some precautions?<br>
<br>
Likely, this is explained in a article on the wiki somewhere, I don't know :-)<div class="m_-4758988475794374764HOEnZb"><div class="m_-4758988475794374764h5"><br>
-- <br>
______________________________<wbr>_________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus-ide.org" target="_blank">Lazarus@lists.lazarus-ide.org</a><br>
<a href="http://lists.lazarus-ide.org/listinfo/lazarus" rel="noreferrer" target="_blank">http://lists.lazarus-ide.org/l<wbr>istinfo/lazarus</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>