U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Widgets - General questions or Mixed problems » How to draw random images in ArrayCtrl-cell using Display? [SOLVED]
Re: How to draw random images in ArrayCtrl-cell using Display? [message #53658 is a reply to message #53656] Sun, 19 April 2020 12:50 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1273
Registered: August 2007
Senior Contributor
Hello slashupp

Quote:
How do I pass an Image as a Value to a Display and access the image in the Display-code so I can draw it?


There is already ImageDisplay(), FittedImageDisplay(), CenteredImageDisplay(), and CenteredHighlightImageDisplay() classes in UPP for this task. You can use them if you are not going to further process the images before they are displayed.

However, if you want to use your code, below code should work.

virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
	{
		w.DrawRect(r, paper);
		Image img = q; // This should be enough if q is a Upp::Image.
		if (!img.IsNullInstance()||img.IsEmpty()) w.DrawImage(r, img);
	}



Or, if you like strict/pedantic code

    const Image& img = q.To<Image>();


This will work too.

Best regards,
Oblivion


[Updated on: Sun, 19 April 2020 12:56]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic: [GLCtrl] Adding an Initilisation function to GLPaint
Next Topic: [Proposal] EditSecret dialogs (EditText variants), for password, etc input..
Goto Forum:
  


Current Time: Wed Jul 22 11:41:54 GMT+2 2026

Total time taken to generate the page: 0.00539 seconds