timage

How do I get the coordinates of the mouse when a control is clicked?

纵饮孤独 提交于 2019-11-29 18:17:12
问题 In a TImage's OnClick event, I would like to extract the x,y coordinates of the mouse. I would prefer them in relation to the image, but in relation to the form or window is just as good. 回答1: Mouse.CursorPos contains the TPoint, which in turn contains the X and Y position. This value is in global coordinates, so you can translate to your form by using the ScreenToClient routine which will translate screen coordinates to window coordinates. According to the Delphi help file, Windows

How to load a small system icon?

馋奶兔 提交于 2019-11-29 06:55:16
I need to display 16x16 pixel icons for error/warning/information. Unfortunately both LoadIcon(0, IDI_*) and LoadImage(0, OIC_*, IMAGE_ICON, 16, 16, LR_SHARED) always give me the 32x32 version of the icon. I read about ShGetStockIconInfo but that is only available from Vista onwards and I still need to support XP. Any ideas? I'm using Delphi 2010 with a TImage component if that matters. The problem is that when you do it this way you get a cached version of the icon, the first one that the system loaded. That will be the large sized icon, typically 32x32. It matters not what size you specify.

How to load an arbitrary image from a BLOB stream into a TImage?

人盡茶涼 提交于 2019-11-29 01:03:18
问题 If I understand it correctly, TImage.LoadFromFile determines the type of picture from the file extension. Is there any way to detect the image type automatically from a TBlobStream with a raw image in it? My current code: procedure LoadImageFromStream(AImage: TImage; ADataSet: TDataSet); var Stream: TStream; begin Stream := ADataSet.CreateBlobStream(Field, bmRead); try AImage.Picture.Graphic.LoadFromStream(Stream); finally Stream.Free; end; end 回答1: See this SO answer for file content

Can I retrieve Filename for TPicture directly?

删除回忆录丶 提交于 2019-11-27 08:42:19
问题 I have a Delphi application which displays an image using a TImage. The location of the image is stored in a database and retrieved on load and set directly using code similar to below: Image1.Picture.LoadFromFile(Query1.FieldByName('image').AsString); I want to be able to display and edit the Filename being loaded during the above, am I right that there is no way to access that directly from the TImage component and that I will need to store the filename separately? 回答1: No, there isn't. You

Scale an image nicely in Delphi?

独自空忆成欢 提交于 2019-11-27 04:19:53
问题 I'm using Delphi 2009 and I'd like to scale an image to fit the available space. the image is always displayed smaller than the original. the problem is TImage Stretch property doesn't do a nice job and harms the picture's readability. (source: xrw.bc.ca) I'd like to see it scaled like this instead: (source: xrw.bc.ca) Any suggestions how best to do this? Tried JVCL, but it doesn't seem to have this ability. A free library would be nice but maybe there's a low cost library that does "only"