www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Blog Post #0062: Cairo Load & Display Images

reply Ron Tarrant <rontarrant gmail.com> writes:
Continuing on with Cairo, this post covers loading and displaying 
three types of image (including a structured drawing) using two 
different load-n-display methods.

As an extra bonus, you'll see a photo of my cat, Bob, and three 
of the seven guitars I've found in my building's recycle room 
over the last year.

https://gtkdcoding.com/2019/08/16/0062-cairo-vi-load-display-images.html
Aug 16 2019
next sibling parent reply bauss <jj_1337 live.dk> writes:
On Friday, 16 August 2019 at 11:42:01 UTC, Ron Tarrant wrote:
 Continuing on with Cairo, this post covers loading and 
 displaying three types of image (including a structured 
 drawing) using two different load-n-display methods.

 As an extra bonus, you'll see a photo of my cat, Bob, and three 
 of the seven guitars I've found in my building's recycle room 
 over the last year.

 https://gtkdcoding.com/2019/08/16/0062-cairo-vi-load-display-images.html
Amazing! You might be able to answer me something, whether you could use gtkd solely for image manipulation using ex. Pixbuf? or would it only work with the internals of gtkd? Like can you manipulate the image and save it to disk etc.
Aug 16 2019
parent reply Ron Tarrant <rontarrant gmail.com> writes:
On Friday, 16 August 2019 at 12:44:15 UTC, bauss wrote:

 Amazing! You might be able to answer me something, whether you 
 could use gtkd solely for image manipulation using ex. Pixbuf? 
 or would it only work with the internals of gtkd? Like can you 
 manipulate the image and save it to disk etc.
Those are very good questions, bauss. I haven't dug in that deep yet, but I see no reason why Cairo couldn't be used to build a full-featured paint, manipulation, or structured drawing application. But it won't only be about Pixbufs. The Cairo Context seems to be where all the action is as far as drawing routines go. Over the next few months, off and on, I'll be exploring stuff like that. I'm still working on getting through all the unsexy stuff first (the basic widgets) but every once in a while, I just have to let my hair down and do something that's a bit more complex. After the basic image and drawing stuff is covered, I'll be digging into simple animation and how to tame the Timeout. Then, after a short side-trip to finish off MVC and do some more base-level widgets such as the Toolbar, Statusbar, and Expander, there's another Cairo miniseries coming up that covers nodes and noodles, something I've wanted to dig into for several years. Thanks for reading and thanks for the kind words.
Aug 17 2019
parent bauss <jj_1337 live.dk> writes:
On Saturday, 17 August 2019 at 19:22:54 UTC, Ron Tarrant wrote:
 On Friday, 16 August 2019 at 12:44:15 UTC, bauss wrote:

 Amazing! You might be able to answer me something, whether you 
 could use gtkd solely for image manipulation using ex. Pixbuf? 
 or would it only work with the internals of gtkd? Like can you 
 manipulate the image and save it to disk etc.
Those are very good questions, bauss. I haven't dug in that deep yet, but I see no reason why Cairo couldn't be used to build a full-featured paint, manipulation, or structured drawing application. But it won't only be about Pixbufs. The Cairo Context seems to be where all the action is as far as drawing routines go. Over the next few months, off and on, I'll be exploring stuff like that. I'm still working on getting through all the unsexy stuff first (the basic widgets) but every once in a while, I just have to let my hair down and do something that's a bit more complex. After the basic image and drawing stuff is covered, I'll be digging into simple animation and how to tame the Timeout. Then, after a short side-trip to finish off MVC and do some more base-level widgets such as the Toolbar, Statusbar, and Expander, there's another Cairo miniseries coming up that covers nodes and noodles, something I've wanted to dig into for several years. Thanks for reading and thanks for the kind words.
Thank you for the answer. I'll take a look at it myself sometime in the near future and see what I can come up with and if I can figure it out :) Also thank you for these blog posts. I enjoy reading them, also the MVC ones.
Aug 17 2019
prev sibling parent reply Andre Pany <andre s-e-a-p.de> writes:
On Friday, 16 August 2019 at 11:42:01 UTC, Ron Tarrant wrote:
 Continuing on with Cairo, this post covers loading and 
 displaying three types of image (including a structured 
 drawing) using two different load-n-display methods.

 As an extra bonus, you'll see a photo of my cat, Bob, and three 
 of the seven guitars I've found in my building's recycle room 
 over the last year.

 https://gtkdcoding.com/2019/08/16/0062-cairo-vi-load-display-images.html
Thanks a lot Ron, your page is really helpful. Is there a reason why the source code starts after a lot of whitespaces on every line? This causes some distruction on mobile phone as you have scroll horizontally although it would fit the screen if the source code would start at column 0. Kind regards Andre
Aug 16 2019
next sibling parent Ron Tarrant <rontarrant gmail.com> writes:
On Friday, 16 August 2019 at 12:58:23 UTC, Andre Pany wrote:

 Thanks a lot Ron, your page is really helpful.
You're welcome, Andre. And thanks for saying so.
 Is there a reason why the source code starts after a lot of 
 whitespaces on every line?
 This causes some distruction on mobile phone as you have scroll 
 horizontally although it would fit the screen if the source 
 code would start at column 0.
Thanks for bringing this to my attention. I've recently switched from basic MD for displaying source and the way I was doing it demanded that everything be indented one tab. I've since switched to Jekyll/Liquid's {% highlight d %} system which doesn't have this limitation. Now that I know this is an issue, give me a some time and I'll get all those extra indents removed.
Aug 17 2019
prev sibling parent reply Ron Tarrant <rontarrant gmail.com> writes:
On Friday, 16 August 2019 at 12:58:23 UTC, Andre Pany wrote:

 This causes some distruction on mobile phone as you have scroll 
 horizontally although it would fit the screen if the source 
 code would start at column 0.
That didn't take as long as I thought it would. I removed all excess indentation, so let me know if it's any better now.
Aug 17 2019
parent reply Andre Pany <andre s-e-a-p.de> writes:
On Saturday, 17 August 2019 at 23:40:10 UTC, Ron Tarrant wrote:
 On Friday, 16 August 2019 at 12:58:23 UTC, Andre Pany wrote:

 This causes some distruction on mobile phone as you have 
 scroll horizontally although it would fit the screen if the 
 source code would start at column 0.
That didn't take as long as I thought it would. I removed all excess indentation, so let me know if it's any better now.
It looks a lot better now. I noticed you use an indentation level of 8 spaces. Is this by purpose? As far as I know, 4 spaces is recommended. Kind regards Andre
Aug 18 2019
parent reply Ron Tarrant <rontarrant gmail.com> writes:
On Sunday, 18 August 2019 at 09:28:30 UTC, Andre Pany wrote:

 II noticed you use an indentation level of 8 spaces. Is this by 
 purpose? As far as I know, 4 spaces is recommended.
I only use three in PS Pad, so the extra spaces are being inserted by either Perl, Jekyll, Liquid, or some part of the GitHub Pages site. Is it possible it's an interpretation layered on by the web browser on your phone? I don't know enough about how browsers work to determine whether or not this is a valid question.
Aug 18 2019
parent reply Andre Pany <andre s-e-a-p.de> writes:
On Sunday, 18 August 2019 at 14:18:23 UTC, Ron Tarrant wrote:
 On Sunday, 18 August 2019 at 09:28:30 UTC, Andre Pany wrote:

 II noticed you use an indentation level of 8 spaces. Is this 
 by purpose? As far as I know, 4 spaces is recommended.
I only use three in PS Pad, so the extra spaces are being inserted by either Perl, Jekyll, Liquid, or some part of the GitHub Pages site. Is it possible it's an interpretation layered on by the web browser on your phone? I don't know enough about how browsers work to determine whether or not this is a valid question.
Hm I am not sure, i just tried lynx (on raspberry pi) and here also the indentation level are 8 spaces. Kind regards Andre
Aug 18 2019
next sibling parent Ron Tarrant <rontarrant gmail.com> writes:
On Sunday, 18 August 2019 at 14:44:29 UTC, Andre Pany wrote:

 Hm I am not sure, i just tried lynx (on raspberry pi) and here 
 also the indentation level are 8 spaces.
Perhaps if I switched from using tabs to spaces... I'll try it with one of the posts and get back to you so you can test it... if that's okay with you.
Aug 18 2019
prev sibling next sibling parent Ron Tarrant <rontarrant gmail.com> writes:
On Sunday, 18 August 2019 at 14:44:29 UTC, Andre Pany wrote:

 Hm I am not sure, i just tried lynx (on raspberry pi) and here 
 also the indentation level are 8 spaces.
Turns out, it's GitHub inserting 8 spaces per tab. No idea why anyone would think this appropriate, but there it is. A workaround you can try for now is to click through to an example code (this won't work on the blog pages, just the code pages) and, at the end of the URL, type: ?ts=3 to get tabs that are three spaces. Any number between 1 and 12 will work, apparently. Hope this helps for now. I'm still looking into this to find a more permanent solution. This 8 spaces per tab bugs me, too.
Aug 18 2019
prev sibling next sibling parent Ron Tarrant <rontarrant gmail.com> writes:
On Sunday, 18 August 2019 at 14:44:29 UTC, Andre Pany wrote:
 Hm I am not sure, i just tried lynx (on raspberry pi) and here 
 also the indentation level are 8 spaces.
For testing purposes, I replaced each tab with three spaces in this post: http://gtkdcoding.com/2019/05/31/0040-messagedialog.html If this works better for you, let me know and I can do a quick s-n-r on all blog posts and add this as the final prep step as the posts go up.
Aug 18 2019
prev sibling parent reply Ron Tarrant <rontarrant gmail.com> writes:
On Sunday, 18 August 2019 at 14:44:29 UTC, Andre Pany wrote:
 the indentation level are 8 spaces.
Turns out it's settable in CSS. Tab size for quoted code blocks in the blog posts is now set to three. If you could check a few out and let me know if it's any better. If not, I'll take it down to two... now that I know how easy it is.
Aug 18 2019
parent reply Andre Pany <andre s-e-a-p.de> writes:
On Sunday, 18 August 2019 at 16:34:21 UTC, Ron Tarrant wrote:
 On Sunday, 18 August 2019 at 14:44:29 UTC, Andre Pany wrote:
 the indentation level are 8 spaces.
Turns out it's settable in CSS. Tab size for quoted code blocks in the blog posts is now set to three. If you could check a few out and let me know if it's any better. If not, I'll take it down to two... now that I know how easy it is.
It looks now very nice, thanks a lot. Wheter you chose 2, 3 or 4 is up to you. 4 is mentioned in Phobos style guide, but it is up to you, what you prefer. Kind regards Andre
Aug 18 2019
parent Ron Tarrant <rontarrant gmail.com> writes:
On Sunday, 18 August 2019 at 17:10:38 UTC, Andre Pany wrote:

 It looks now very nice, thanks a lot.
Excellent. Glad to do it.
 Wheter you chose 2, 3 or 4 is up to you. 4 is mentioned in 
 Phobos style guide, but it is up to you, what you prefer.
I've always been partial to three, but I'm also more of a tab person. Less work, if you see what I'm saying.
Aug 18 2019