Re: Easiest way to display images

2019-03-12 Thread Adam D. Ruppe via Digitalmars-d-learn

On Tuesday, 12 March 2019 at 02:21:51 UTC, Murilo wrote:

Hi Adam, how do I set the color of the SimpleWindow background?


You have to draw a rectangle on the window to make your own 
background. Set both outlineColor and fillColor to the same 
thing, then do painter.drawRectangle(Point(0, 0), 
Size(window.width, window.height));


Re: Easiest way to display images

2019-03-11 Thread Murilo via Digitalmars-d-learn

Hi Adam, how do I set the color of the SimpleWindow background?


Re: Easiest way to display images

2019-02-25 Thread Adam D. Ruppe via Digitalmars-d-learn

On Monday, 25 February 2019 at 22:34:54 UTC, Murilo wrote:
Hi Adam. I am using your library. There is the ScreenPainter 
struct and it has a method called .eventLoop(), how do I make 
it stop after a certain amount of loops? I would like to be 
able to call it several times in the program.


I fear your program is poorly designed, that kind of thing 
shouldn't be necessary.


But it is possible by using the EventLoop struct directly.

http://dpldocs.info/experimental-docs/arsd.simpledisplay.EventLoop.html


EventLoop.get.exit() will exit the loop, though it may not want 
to start up again (I have never tried).


You can also do something like, after setting it all up,

bool done;
EventLoop el = EventLoop.get;
el.run(() { return !done; });


And that delegate you pass to `run` tells it when to return.


Re: Easiest way to display images

2019-02-25 Thread Murilo via Digitalmars-d-learn

On Tuesday, 12 February 2019 at 01:31:48 UTC, Adam D. Ruppe wrote:

On Tuesday, 12 February 2019 at 01:16:21 UTC, Murilo wrote:
Hi Adam. I have been using your arsd library and I have 
noticed that compiling with -m64 causes this error:


huh, only on 64 bit windows.

well, pushed a fix up, try the new version


Hi Adam. I am using your library. There is the ScreenPainter 
struct and it has a method called .eventLoop(), how do I make it 
stop after a certain amount of loops? I would like to be able to 
call it several times in the program.


Re: Easiest way to display images

2019-02-11 Thread Murilo via Digitalmars-d-learn

On Tuesday, 12 February 2019 at 01:31:48 UTC, Adam D. Ruppe wrote:

On Tuesday, 12 February 2019 at 01:16:21 UTC, Murilo wrote:
Hi Adam. I have been using your arsd library and I have 
noticed that compiling with -m64 causes this error:


huh, only on 64 bit windows.

well, pushed a fix up, try the new version


Forget about it, I just fixed it myself. :) I am so happy, I did 
not think I would be able to do it on my own, I guess all those 
years of studying were worth the effort, I read the error message 
and figured it was something wrong in the module jpeg.d so I 
opened it, read the code(in a very fast manner) and discovered 
that the calls to core.stdc.stdlib.alloca() were causing the 
problem apart from being unnecessary so I just commented all of 
them out(just like you did with the very first instance) and then 
there was a problem with the buffer variable which was only 
defined by you in the first instance so I just defined it in the 
other instances following the same method you used and it all 
worked in the end. I will submit a pull request on your GitHub 
page. Cheers.


Re: Easiest way to display images

2019-02-11 Thread Murilo via Digitalmars-d-learn

On Tuesday, 12 February 2019 at 01:31:48 UTC, Adam D. Ruppe wrote:

On Tuesday, 12 February 2019 at 01:16:21 UTC, Murilo wrote:
Hi Adam. I have been using your arsd library and I have 
noticed that compiling with -m64 causes this error:


huh, only on 64 bit windows.

well, pushed a fix up, try the new version


Hi, unfortunately the problem persists. I have sent you an e-mail 
on your destructiona...@gmail.com account. I would prefer to talk 
there rather than here. I would just like to understand what is 
causing the problem so I can figure out a bypass.


Re: Easiest way to display images

2019-02-11 Thread Adam D. Ruppe via Digitalmars-d-learn

On Tuesday, 12 February 2019 at 01:16:21 UTC, Murilo wrote:
Hi Adam. I have been using your arsd library and I have noticed 
that compiling with -m64 causes this error:


huh, only on 64 bit windows.

well, pushed a fix up, try the new version


Re: Easiest way to display images

2019-02-11 Thread Murilo via Digitalmars-d-learn

On Sunday, 10 February 2019 at 21:26:56 UTC, Adam D. Ruppe wrote:

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


Hi Adam. I have been using your arsd library and I have noticed 
that compiling with -m64 causes this error:
Error: cannot mix core.std.stdlib.alloca() and exception handling 
in _D4arsd4jpeg27detect_jpeg_image_from_fileFAxaJiJiJiZb()

May I know why that happens? How can I bypass it?


Re: Easiest way to display images

2019-02-10 Thread Murilo via Digitalmars-d-learn

On Sunday, 10 February 2019 at 21:26:56 UTC, Adam D. Ruppe wrote:

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


okay, I will try that, but do you have a facebook account? I 
usually chat with people on facebook.


Re: Easiest way to display images

2019-02-10 Thread Adam D. Ruppe via Digitalmars-d-learn

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


Re: Easiest way to display images

2019-02-10 Thread Murilo via Digitalmars-d-learn
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.


Re: Easiest way to display images

2019-02-06 Thread DanielG via Digitalmars-d-learn

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.





Re: Easiest way to display images

2019-02-06 Thread Murilo via Digitalmars-d-learn

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.


Re: Easiest way to display images

2019-02-05 Thread DanielG via Digitalmars-d-learn

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.


Re: Easiest way to display images

2019-02-05 Thread Adam D. Ruppe via Digitalmars-d-learn

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.


Re: Easiest way to display images

2019-02-05 Thread Murilo via Digitalmars-d-learn

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/




Re: Easiest way to display images

2019-02-05 Thread Murilo via Digitalmars-d-learn

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.


Re: Easiest way to display images

2019-02-05 Thread Adam D. Ruppe via Digitalmars-d-learn

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.


Easiest way to display images

2019-02-05 Thread Murilo via Digitalmars-d-learn
What would be the easiest way to simply display a jpg or png 
image on the screen for a few seconds in Windows?