www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - arsd png bug

reply Joerg Joergonson <JJoergonson gmail.com> writes:
1810:
		case 3:
			auto arr = data.dup;
			foreach(i; 0 .. arr.length) {
				auto prev = i < bpp ? 0 : arr[i - bpp];
				if (i >= previousLine.length) break;
				arr[i] += cast(ubyte)
					/*std.math.floor*/( cast(int) (prev + previousLine[i]) / 2);
			}


adding
	if (i >= previousLine.length) break;

prevents some crashes and seems to work.
Jun 20 2016
next sibling parent reply Alex Parrill <initrd.gz gmail.com> writes:
On Monday, 20 June 2016 at 21:39:45 UTC, Joerg Joergonson wrote:
 1810:
 		case 3:
 			auto arr = data.dup;
 			foreach(i; 0 .. arr.length) {
 				auto prev = i < bpp ? 0 : arr[i - bpp];
 				if (i >= previousLine.length) break;
 				arr[i] += cast(ubyte)
 					/*std.math.floor*/( cast(int) (prev + previousLine[i]) / 
 2);
 			}


 adding
 	if (i >= previousLine.length) break;

 prevents some crashes and seems to work.
You'd probably get better results by filing an issue with the project's bug tracker [1]. Also by including a sample image that causes the crash. [1]: https://github.com/adamdruppe/arsd/issues
Jun 20 2016
parent Adam D. Ruppe <destructionator gmail.com> writes:
On Monday, 20 June 2016 at 21:53:42 UTC, Alex Parrill wrote:
 You'd probably get better results by filing an issue with the 
 project's bug tracker [1]. Also by including a sample image 
 that causes the crash.
It doesn't make much of a difference to me, it all just ends up in my email inbox anyway.
Jun 20 2016
prev sibling parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Monday, 20 June 2016 at 21:39:45 UTC, Joerg Joergonson wrote:
 adding
 	if (i >= previousLine.length) break;

 prevents some crashes and seems to work.
So previousLine should be either the right length or null, so I put in one test. Can you try it on your test image? BTW I do a few unnecessary duplications in here too. I think. But there's surely some potential for more memory/performance improvements here.
Jun 20 2016
parent Joerg Joergonson <JJoergonson gmail.com> writes:
On Tuesday, 21 June 2016 at 00:31:51 UTC, Adam D. Ruppe wrote:
 On Monday, 20 June 2016 at 21:39:45 UTC, Joerg Joergonson wrote:
 adding
 	if (i >= previousLine.length) break;

 prevents some crashes and seems to work.
So previousLine should be either the right length or null, so I put in one test. Can you try it on your test image? BTW I do a few unnecessary duplications in here too. I think. But there's surely some potential for more memory/performance improvements here.
I'll update but can't do any tests since it's random. Seems to be something different with the png encoding. They are auto generated and I've already overwritten the ones that create the bug. (so if it's fixed it will just never occur again, if not it will happen sometime in the future again and I'll let you know). Every time I've checked it's been previousLine being null and simply putting in that check fixed it, so it is just probably some strange edge case.
Jun 20 2016