Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » RichText,QTF,RTF... » how can i get the image in the RichText?
icon3.gif  how can i get the image in the RichText? [message #54455] Sat, 25 July 2020 05:42 Go to next message
jimo is currently offline  jimo
Messages: 2
Registered: July 2020
Junior Member
RichEdit edt;
// then i pasted a image to the edt from cliboard

const RichText& rt = edt.Get();
// how can i get the image from RichText?


tks!
Re: how can i get the image in the RichText? [message #54475 is a reply to message #54455] Wed, 29 July 2020 10:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12616
Registered: November 2005
Ultimate Member
jimo wrote on Sat, 25 July 2020 05:42
RichEdit edt;
// then i pasted a image to the edt from cliboard

const RichText& rt = edt.Get();
// how can i get the image from RichText?


tks!


Well, there can be more than one... Smile

However, if you want to get all of them, then the easy way is to use RichText::Iterator to iterate through all paragraphs, then RichPara::GetCount, RichPara::operator[] to iterate through all paragraph parts, check if that is object, convert the object to its natural size and paint it...

Mirek
Re: how can i get the image in the RichText? [message #54477 is a reply to message #54475] Wed, 29 July 2020 11:01 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12616
Registered: November 2005
Ultimate Member
Vector<Image> ExtractImages(const RichText& txt)
{
	struct Iter : RichText::Iterator {
		Vector<Image> m;
		virtual bool operator()(int, const RichPara& para) {
			for(int i = 0; i < para.GetCount(); i++) {
				const RichPara::Part& p = para[i];
				if(p.object)
					m.Add(p.object.ToImage(p.object.GetPixelSize()));
			}
			return false;
		}
	} iter;

	txt.Iterate(iter);
	
	return pick(iter.m);
}


(Now added as reference example).
Re: how can i get the image in the RichText? [message #54478 is a reply to message #54477] Wed, 29 July 2020 11:14 Go to previous messageGo to next message
jimo is currently offline  jimo
Messages: 2
Registered: July 2020
Junior Member
Thx mirek

i'm writing a little chat program,
the other question is How to change the backcolor when selecting .
i think the invert color is ugly ... Confused

index.php?t=getfile&id=6155&private=0

index.php?t=getfile&id=6156&private=0
  • Attachment: 1.png
    (Size: 42.51KB, Downloaded 51 times)
  • Attachment: 2.png
    (Size: 50.13KB, Downloaded 50 times)
Re: how can i get the image in the RichText? [message #54480 is a reply to message #54478] Wed, 29 July 2020 12:09 Go to previous message
mirek is currently offline  mirek
Messages: 12616
Registered: November 2005
Ultimate Member
That needs changes in RichText/RichEdit.

However, why not... I have now added DrawSelection field to PaintInfo to customize the appearance. This is now possible in the trunk:

	RichEditWithToolBar e;
	PaintInfo pi;
	pi.DrawSelection = [](Draw& dw, int x, int y, int cx, int cy) {
		static Image m;
		ONCELOCK {
			m = CreateImage(Size(128, 128), 50 * Blue());
		}
		dw.Clip(x, y, cx, cy);
		for(int w = 0; w < cx; w += 128)
			for(int h = 0; h < cy; h += 128)
				dw.DrawImage(x + w, y + h, m);
		dw.End();
	};
	e.SetPaintInfo(pi);

[Updated on: Wed, 29 July 2020 12:09]

Report message to a moderator

Previous Topic: how to solve WhenEnter event to RichEdit
Goto Forum:
  


Current Time: Wed Aug 12 05:26:44 CEST 2020

Total time taken to generate the page: 0.00929 seconds