Jump to page: 1 2
Thread overview
Easiest way to display images
Feb 05
Murilo
Feb 06
Murilo
Feb 06
Murilo
Feb 10
Murilo
Feb 10
Murilo
6 days ago
Murilo
6 days ago
Adam D. Ruppe
6 days ago
Murilo
6 days ago
Murilo
Feb 06
DanielG
Feb 07
Murilo
Feb 07
DanielG
February 05
What would be the easiest way to simply display a jpg or png image on the screen for a few seconds in Windows?
February 05
On Tuesday, 5 February 2019 at 21:11:52 UTC, Murilo wrote:
> What would be the easiest way to simply display a jpg or png image on the screen for a few seconds in Windows?

That's a little more complex than playing a sound, there's no one function to do it. You can in... oh about 50 lines, but I can't write them off the top of my head.

However, I do have a library that can do it in 5 lines.

---
import arsd.simpledisplay;
import arsd.image;

void main() {
	displayImage(Image.fromMemoryImage(loadImageFromFile("filename here")));
}
---

I realize that line is a bit silly looking, it loads a file, converts it to a displayable format, then pops up a window to display it. Any key pressed in the window will close it.

You might need something more complex, and the lib can do it. You might also want something less complex (that `arsd.image` actually loads 7 different modules for various image formats), but it isn't super hard to use anyway:

Download the code here:

https://github.com/adamdruppe/arsd

You can put all those files in an `arsd` folder next to your program, and `dmd -i yourfile.d` to compile it all at once.

Or if you want to load the files yourself, you can list them all. If you just need png and/or jpeg specifically, you can jus get jpeg.d and/or png.d, together with simpledisplay.d and color.d from the repo and call these functions:

http://dpldocs.info/experimental-docs/arsd.jpeg.readJpeg.html
http://dpldocs.info/experimental-docs/arsd.png.readPng.html


So the code looks like:
---
import arsd.simpledisplay;
import arsd.png;

void main() {
	displayImage(Image.fromMemoryImage(loadPng("filename here")));
}
---

or of course changing png to jpeg if you want that. (You can put that on an if based on the image filename - that's what the arsd.image library actually does).

Then compile:

dmd yourfile.d color.d simpledisplay.d png.d jpeg.d



But the first option with dmd -i is prolly the easiest.



If you need mroe control over the window, let me know, I will type that up too.

also take a look at the docs http://dpldocs.info/experimental-docs/arsd.simpledisplay.html



BTW I didn't mention this in your other thread because PlaySound is easier to use anyway, but I also have an audio module: http://dpldocs.info/experimental-docs/arsd.simpleaudio.html I'm just not 100% happy with it so I don't talk about it much.
February 06
On Tuesday, 5 February 2019 at 21:25:54 UTC, Adam D. Ruppe wrote:
> On Tuesday, 5 February 2019 at 21:11:52 UTC, Murilo wrote:
>> What would be the easiest way to simply display a jpg or png image on the screen for a few seconds in Windows?
>
> That's a little more complex than playing a sound, there's no one function to do it. You can in... oh about 50 lines, but I can't write them off the top of my head.
>
> However, I do have a library that can do it in 5 lines.
>
> ---
> import arsd.simpledisplay;
> import arsd.image;
>
> void main() {
> 	displayImage(Image.fromMemoryImage(loadImageFromFile("filename here")));
> }
> 


Thank you so but so much. I tested it here and it works.
February 06
On Tuesday, 5 February 2019 at 21:25:54 UTC, Adam D. Ruppe wrote:
> On Tuesday, 5 February 2019 at 21:11:52 UTC, Murilo wrote:
>> What would be the easiest way to simply display a jpg or png image on the screen for a few seconds in Windows?
>
> That's a little more complex than playing a sound, there's no one function to do it. You can in... oh about 50 lines, but I can't write them off the top of my head.

You should later joing the facebook group Programming in D. There you could show your library, lots of people would like to use it.
https://www.facebook.com/groups/662119670846705/


February 06
On Wednesday, 6 February 2019 at 01:04:43 UTC, Murilo wrote:
> You should later joing the facebook group Programming in D.

Eh, I don't really like facebook groups.

With my libraries too, I don't really care if anyone uses them. I make them for myself and put them online because it is easy for me. I don't count downloads or anything; it just means nothing to me.
February 06
On Wednesday, 6 February 2019 at 01:04:43 UTC, Murilo wrote:
> You should later joing the facebook group Programming in D.

The D community is small enough that it's unlikely anybody in that Facebook group, isn't already using the newsgroups / IRC / etc to discuss D. Even the official subreddit barely gets any traffic.

What I'm trying to say is, you're not going to have much luck getting that Facebook group off the ground. FB adds nothing to the existing options, and worse it's just an elaborate scheme to harvest personal information which one can safely assume the vast majority of D programmers are privacy-savvy enough to avoid.
February 07
On Wednesday, 6 February 2019 at 04:36:12 UTC, DanielG wrote:
> On Wednesday, 6 February 2019 at 01:04:43 UTC, Murilo wrote:
>> You should later joing the facebook group Programming in D.
>
> The D community is small enough that it's unlikely anybody in that Facebook group, isn't already using the newsgroups / IRC / etc to discuss D. Even the official subreddit barely gets any traffic.
>
> What I'm trying to say is, you're not going to have much luck getting that Facebook group off the ground. FB adds nothing to the existing options, and worse it's just an elaborate scheme to harvest personal information which one can safely assume the vast majority of D programmers are privacy-savvy enough to avoid.

The facebook group already has 82 members, some of which are experienced users of D. There has been some reasonable amount of discussions going on there in the last weeks. And you don't need to worry about the "information harvesting" if you don't post personal stuff. It is a group to talk about a language and not about your life.
February 07
On Thursday, 7 February 2019 at 00:10:50 UTC, Murilo wrote:
> "information harvesting"

I mean Facebook as a whole, not your group specifically. FB is in the business of selling to advertisers, and the users are the product.


February 10
On Wednesday, 6 February 2019 at 03:35:03 UTC, Adam D. Ruppe wrote:
> On Wednesday, 6 February 2019 at 01:04:43 UTC, Murilo wrote:
>> You should later joing the facebook group Programming in D.
>
> Eh, I don't really like facebook groups.
>
> With my libraries too, I don't really care if anyone uses them. I make them for myself and put them online because it is easy for me. I don't count downloads or anything; it just means nothing to me.

Adam, is there a place where we can chat? I don't like chatting via this forum. I would like to talk to you about your modules and about the D lang.
February 10
On Sunday, 10 February 2019 at 18:42:59 UTC, Murilo wrote:
> Adam, is there a place where we can chat? I don't like chatting via this forum. I would like to talk to you about your modules and about the D lang.

get on the freenode irc, i am in #d like all the time (and will see messages when i am back on my computer) or you can dm me adam_d_ruppe there if i am online
« First   ‹ Prev
1 2