April 26

On Tuesday, 26 April 2022 at 21:13:38 UTC, Alexander Zhirov wrote:

>

more build errors

If you "dub upgrade" it should work a bit better.
No success in reproducing the bug here.

April 27
On 27/04/2022 9:39 AM, Guillaume Piolat wrote:
> On Tuesday, 26 April 2022 at 21:13:38 UTC, Alexander Zhirov wrote:
>> more build errors
> 
> If you "dub upgrade" it should work a bit better.
> No success in reproducing the bug here.

It definitely on your end.

void main() {
    int scale;
    int* in_ = new int;
    ubyte b = cast(int)scale * (cast(int)*in_ >> 7);
}

onlineapp.d(5): Error: cannot implicitly convert expression `scale * (*in_ >> 7)` of type `int` to `ubyte`
April 26
On Tuesday, 26 April 2022 at 21:44:56 UTC, rikki cattermole wrote:
>
> On 27/04/2022 9:39 AM, Guillaume Piolat wrote:
>> On Tuesday, 26 April 2022 at 21:13:38 UTC, Alexander Zhirov wrote:
>>> more build errors
>> 
>> If you "dub upgrade" it should work a bit better.
>> No success in reproducing the bug here.
>
> It definitely on your end.
>
> void main() {
>     int scale;
>     int* in_ = new int;
>     ubyte b = cast(int)scale * (cast(int)*in_ >> 7);
> }
>
> onlineapp.d(5): Error: cannot implicitly convert expression `scale * (*in_ >> 7)` of type `int` to `ubyte`

No.
Obviously VRP works differently for me and for him, for an unknown reason.
April 27
On 27/04/2022 9:55 AM, Guillaume Piolat wrote:
> On Tuesday, 26 April 2022 at 21:44:56 UTC, rikki cattermole wrote:
>>
>> On 27/04/2022 9:39 AM, Guillaume Piolat wrote:
>>> On Tuesday, 26 April 2022 at 21:13:38 UTC, Alexander Zhirov wrote:
>>>> more build errors
>>>
>>> If you "dub upgrade" it should work a bit better.
>>> No success in reproducing the bug here.
>>
>> It definitely on your end.
>>
>> void main() {
>>     int scale;
>>     int* in_ = new int;
>>     ubyte b = cast(int)scale * (cast(int)*in_ >> 7);
>> }
>>
>> onlineapp.d(5): Error: cannot implicitly convert expression `scale * (*in_ >> 7)` of type `int` to `ubyte`
> 
> No.
> Obviously VRP works differently for me and for him, for an unknown reason.

I copied and pasted the same code that is failing from the file in question and put it into that test code.

Putting an int into a ubyte absolutely should error, that is a lossy conversion and should not be automatic.
April 26
On Tuesday, 26 April 2022 at 21:59:39 UTC, rikki cattermole wrote:
>
> Putting an int into a ubyte absolutely should error, that is a lossy conversion and should not be automatic.

It's just VRP, here it works in 2.094
https://d.godbolt.org/z/vjq7xsMdn

because the compiler wasn't complaining I wouldn't know it was reliant on VRP (which is certainly an issue to be fixed).
April 27
On 27/04/2022 10:05 AM, Guillaume Piolat wrote:
> On Tuesday, 26 April 2022 at 21:59:39 UTC, rikki cattermole wrote:
>>
>> Putting an int into a ubyte absolutely should error, that is a lossy conversion and should not be automatic.
> 
> It's just VRP, here it works in 2.094
> https://d.godbolt.org/z/vjq7xsMdn
> 
> because the compiler wasn't complaining I wouldn't know it was reliant on VRP (which is certainly an issue to be fixed).

Okay further testing locally, I cannot reproduce.

Of course I still don't think that code is right and should have the casts.

Either way whatever the dmd is, it must not be as recent as thought to be.
April 26
On Tuesday, 26 April 2022 at 22:16:15 UTC, rikki cattermole wrote:
> Of course I still don't think that code is right and should have the casts.

Absolutely. I'm a bit anxious about "accidental VRP" now, not sure if the checks fluctuate from version to version, or worse, depends upon the platform.
April 27
On Tuesday, 26 April 2022 at 18:31:49 UTC, H. S. Teoh wrote:
> maybe look at Adam Ruppe's arsd library (https://github.com/adamdruppe/arsd) for some lightweight modules that read common image formats and do some primitive image manipulations.

I don't actually have an image to image blit function, but writing one is trivial - just loop over it and call alphaBlend.

It can load ttf fonts, render them to bitmaps, load images, combined them, then save images. Can even load ttfs off the operating system if you wanted to use those.... or even have the OS functions do the drawing instead of diy, but probably easier to diy this simple case.

Sample code would be:

---
import arsd.image;
import arsd.ttf;

void main() {
	auto image = loadImageFromFile("/home/me/small-clouds.png");
	if(image is null)
		throw new Exception("Couldn't load the image file");
	auto tci = image.getAsTrueColorImage(); // convert to rgba for simplicity

	import std.file;
	auto font = TtfFont(cast(ubyte[]) std.file.read("/home/me/arsd/sans-serif.ttf"));

	int width, height;
	auto bitmap = font.renderString("Hello", 14, width, height); // it populates width and height fyi

	// where we want to put it
	int xput = 30;
	int yput = 20;

	int bitmapOffset = 0;

	// color to draw the text
	int r = 255;
	int g = 0;
	int b = 0;

	foreach(y; 0 .. height) {
		if(y + yput >= image.height)
			break;
		foreach(x; 0 .. width) {
			scope(exit) bitmapOffset++; // always advance this as long as we're still drawing...
			// but don't draw out of bounds
			if(x + xput >= image.width)
				continue;

			// replace a pixel with the blended version of the text bitmap
			image.setPixel(
				xput + x, yput + y,
				image.getPixel(xput + x, yput + y).
					alphaBlend(Color(r, g, b, bitmap[bitmapOffset]))
			);
		}
	}

	import arsd.png;
	writePng("text-image.png", image); // save it back to a png
}
---


Open the text-image.png to see the result. (Or:
---
    import arsd.simpledisplay;
    displayImage(Image.fromMemoryImage(image));
---
to display it in a window right from your program!)



My libs are available as individual files from the github - you might just use png instead of the whole image.d to avoid needing additional files for formats you don't need - or you can pull it on dub under the arsd-official:image_files package and arsd-official:ttf.
April 27

On Wednesday, 27 April 2022 at 00:03:25 UTC, Adam Ruppe wrote:

>

Sample code would be:

Ego have problems cum scribendarum hic quoque, fortasse opus est dare aliquid aliud, cum componendis?

~/programming/d/pic $ dmd app.d
/usr/bin/ld: app.o:(.data.rel.ro+0x10): undefined reference «_D4arsd5image12__ModuleInfoZ»
/usr/bin/ld: app.o:(.data.rel.ro+0x30): undefined reference «_D4arsd3png12__ModuleInfoZ»
/usr/bin/ld: app.o: в функции «_Dmain»:
app.d:(.text._Dmain[_Dmain]+0xcb): undefined reference «_D4arsd3ttf7TtfFont6__ctorMFNcIAhZSQBhQBfQBe»
/usr/bin/ld: app.d:(.text._Dmain[_Dmain]+0xfb): undefined reference «_D4arsd3ttf7TtfFont12renderStringMFIAaiJiJiZAh»
/usr/bin/ld: app.d:(.text._Dmain[_Dmain]+0x297): undefined reference «_D4arsd5color5Color6__ctorMFNaNbNcNiNfiiiiZSQBqQBoQBl»
/usr/bin/ld: app.d:(.text._Dmain[_Dmain]+0x2a2): undefined reference «_D4arsd5color5Color10alphaBlendMxFNaNbNiNeSQBpQBnQBkZQl»
/usr/bin/ld: app.d:(.text._Dmain[_Dmain]+0x31a): undefined reference «_D4arsd3png8writePngFAyaCQx5color11MemoryImageZv»
/usr/bin/ld: app.o: в функции «_D4arsd5image__T17loadImageFromFileHTAyaZQzFQhZCQBu5color11MemoryImage»:
app.d:(.text._D4arsd5image__T17loadImageFromFileHTAyaZQzFQhZCQBu5color11MemoryImage[_D4arsd5image__T17loadImageFromFileHTAyaZQzFQhZCQBu5color11MemoryImage]+0x1f): undefined reference «_D4arsd5image29guessImageFormatFromExtensionFAxaZEQBwQBu15ImageFileFormat»
/usr/bin/ld: app.d:(.text._D4arsd5image__T17loadImageFromFileHTAyaZQzFQhZCQBu5color11MemoryImage[_D4arsd5image__T17loadImageFromFileHTAyaZQzFQhZCQBu5color11MemoryImage]+0x1d8): undefined reference «_D4arsd5image19loadImageFromMemoryFAxvZCQBm5color11MemoryImage»
/usr/bin/ld: app.d:(.text._D4arsd5image__T17loadImageFromFileHTAyaZQzFQhZCQBu5color11MemoryImage[_D4arsd5image__T17loadImageFromFileHTAyaZQzFQhZCQBu5color11MemoryImage]+0x297): undefined reference «_D4arsd3png7readPngFAyaZCQx5color11MemoryImage»
/usr/bin/ld: app.d:(.text._D4arsd5image__T17loadImageFromFileHTAyaZQzFQhZCQBu5color11MemoryImage[_D4arsd5image__T17loadImageFromFileHTAyaZQzFQhZCQBu5color11MemoryImage]+0x2a9): undefined reference «_D4arsd3bmp7readBmpFAyaZCQx5color11MemoryImage»
/usr/bin/ld: app.d:(.text._D4arsd5image__T17loadImageFromFileHTAyaZQzFQhZCQBu5color11MemoryImage[_D4arsd5image__T17loadImageFromFileHTAyaZQzFQhZCQBu5color11MemoryImage]+0x2bb): undefined reference «_D4arsd4jpeg8readJpegFAxaZCQz5color11MemoryImage»
/usr/bin/ld: app.d:(.text._D4arsd5image__T17loadImageFromFileHTAyaZQzFQhZCQBu5color11MemoryImage[_D4arsd5image__T17loadImageFromFileHTAyaZQzFQhZCQBu5color11MemoryImage]+0x341): undefined reference «_D4arsd5image7readSvgFAyaZCQz5color11MemoryImage»
/usr/bin/ld: app.o: в функции «_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZCQCf5color11MemoryImage»:
app.d:(.text._D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZCQCf5color11MemoryImage[_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZCQCf5color11MemoryImage]+0x9ab): undefined reference «_D4arsd5color14TrueColorImage7__ClassZ»
/usr/bin/ld: app.d:(.text._D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZCQCf5color11MemoryImage[_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZCQCf5color11MemoryImage]+0x9c6): undefined reference «_D4arsd5color14TrueColorImage6__ctorMFNaNbNfiiZCQBuQBsQBp»
/usr/bin/ld: app.d:(.text._D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZCQCf5color11MemoryImage[_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZCQCf5color11MemoryImage]+0xa01): undefined reference «_D4arsd5color14TrueColorImage4Data6colorsMNgFNaNbNdNiNeZANgSQCgQCe5Color»
/usr/bin/ld: app.d:(.text._D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZCQCf5color11MemoryImage[_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZCQCf5color11MemoryImage]+0xc12): undefined reference «_D4arsd5color14TrueColorImage4Data6colorsMNgFNaNbNdNiNeZANgSQCgQCe5Color»
/usr/bin/ld: app.d:(.text._D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZCQCf5color11MemoryImage[_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZCQCf5color11MemoryImage]+0xd02): undefined reference «_D4arsd5color14TrueColorImage4Data6colorsMNgFNaNbNdNiNeZANgSQCgQCe5Color»
/usr/bin/ld: app.d:(.text._D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZCQCf5color11MemoryImage[_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZCQCf5color11MemoryImage]+0xd5e): undefined reference «_D4arsd5color14TrueColorImage4Data6colorsMNgFNaNbNdNiNeZANgSQCgQCe5Color»
/usr/bin/ld: app.o: в функции «_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T11readColor16Vbi0ZQsMFMDFZhZSQDk5color5Color»:
app.d:(.text._D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T11readColor16Vbi0ZQsMFMDFZhZSQDk5color5Color[_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T11readColor16Vbi0ZQsMFMDFZhZSQDk5color5Color]+0xab): undefined reference «_D4arsd5color5Color6__ctorMFNaNbNcNiNfiiiiZSQBqQBoQBl»
/usr/bin/ld: app.o: в функции «_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T13readColorTrueVbi0Vki3ZQyMFMDFZhZSQDq5color5Color»:
app.d:(.text._D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T13readColorTrueVbi0Vki3ZQyMFMDFZhZSQDq5color5Color[_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T13readColorTrueVbi0Vki3ZQyMFMDFZhZSQDq5color5Color]+0x6f): undefined reference «_D4arsd5color5Color6__ctorMFNaNbNcNiNfiiiiZSQBqQBoQBl»
/usr/bin/ld: app.o: в функции «_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T13readColorTrueVbi0Vki4ZQyMFMDFZhZSQDq5color5Color»:
app.d:(.text._D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T13readColorTrueVbi0Vki4ZQyMFMDFZhZSQDq5color5Color[_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T13readColorTrueVbi0Vki4ZQyMFMDFZhZSQDq5color5Color]+0x6f): undefined reference «_D4arsd5color5Color6__ctorMFNaNbNcNiNfiiiiZSQBqQBoQBl»
/usr/bin/ld: app.o: в функции «_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T11readColor16Vbi1ZQsMFMDFZhZSQDk5color5Color»:
app.d:(.text._D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T11readColor16Vbi1ZQsMFMDFZhZSQDk5color5Color[_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T11readColor16Vbi1ZQsMFMDFZhZSQDk5color5Color]+0xab): undefined reference «_D4arsd5color5Color6__ctorMFNaNbNcNiNfiiiiZSQBqQBoQBl»
/usr/bin/ld: app.o: в функции «_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T13readColorTrueVbi1Vki3ZQyMFMDFZhZSQDq5color5Color»:
app.d:(.text._D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T13readColorTrueVbi1Vki3ZQyMFMDFZhZSQDq5color5Color[_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T13readColorTrueVbi1Vki3ZQyMFMDFZhZSQDq5color5Color]+0x6f): undefined reference «_D4arsd5color5Color6__ctorMFNaNbNcNiNfiiiiZSQBqQBoQBl»
/usr/bin/ld: app.o:app.d:(.text._D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T13readColorTrueVbi1Vki4ZQyMFMDFZhZSQDq5color5Color[_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ__T13readColorTrueVbi1Vki4ZQyMFMDFZhZSQDq5color5Color]+0x6f): далее есть ещё неопределённые ссылки на «_D4arsd5color5Color6__ctorMFNaNbNcNiNfiiiiZSQBqQBoQBl»
/usr/bin/ld: app.o: в функции «_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ12loadColormapMFZv»:
app.d:(.text._D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ12loadColormapMFZv[_D4arsd5targa__T11loadTgaImplTS3std5stdio4FileZQBfFKQwAxaZ12loadColormapMFZv]+0x1d3): undefined reference «_D4arsd5color5Color5blackFNaNbNiNfZSQBiQBgQBd»
/usr/bin/ld: app.o: в функции «_D4arsd3pcx__T11loadPcxImplTS3std5stdio4FileZQBfFKQwAxaZCQCd5color11MemoryImage»:
app.d:(.text._D4arsd3pcx__T11loadPcxImplTS3std5stdio4FileZQBfFKQwAxaZCQCd5color11MemoryImage[_D4arsd3pcx__T11loadPcxImplTS3std5stdio4FileZQBfFKQwAxaZCQCd5color11MemoryImage]+0x62a): undefined reference «_D4arsd5color12IndexedImage7__ClassZ»
/usr/bin/ld: app.d:(.text._D4arsd3pcx__T11loadPcxImplTS3std5stdio4FileZQBfFKQwAxaZCQCd5color11MemoryImage[_D4arsd3pcx__T11loadPcxImplTS3std5stdio4FileZQBfFKQwAxaZCQCd5color11MemoryImage]+0x643): undefined reference «_D4arsd5color12IndexedImage6__ctorMFNaNbNfiiZCQBsQBqQBn»
/usr/bin/ld: app.d:(.text._D4arsd3pcx__T11loadPcxImplTS3std5stdio4FileZQBfFKQwAxaZCQCd5color11MemoryImage[_D4arsd3pcx__T11loadPcxImplTS3std5stdio4FileZQBfFKQwAxaZCQCd5color11MemoryImage]+0x653): undefined reference «_D4arsd5color14TrueColorImage7__ClassZ»
/usr/bin/ld: app.d:(.text._D4arsd3pcx__T11loadPcxImplTS3std5stdio4FileZQBfFKQwAxaZCQCd5color11MemoryImage[_D4arsd3pcx__T11loadPcxImplTS3std5stdio4FileZQBfFKQwAxaZCQCd5color11MemoryImage]+0x66c): undefined reference «_D4arsd5color14TrueColorImage6__ctorMFNaNbNfiiZCQBuQBsQBp»
/usr/bin/ld: app.d:(.text._D4arsd3pcx__T11loadPcxImplTS3std5stdio4FileZQBfFKQwAxaZCQCd5color11MemoryImage[_D4arsd3pcx__T11loadPcxImplTS3std5stdio4FileZQBfFKQwAxaZCQCd5color11MemoryImage]+0xa21): undefined reference «_D4arsd5color5Color6__ctorMFNaNbNcNiNfiiiiZSQBqQBoQBl»
/usr/bin/ld: app.o:(.data._D27TypeInfo_S4arsd5color5Color6__initZ+0x48): undefined reference «_D4arsd5color5Color8toStringMxFNfZAya»
/usr/bin/ld: app.o: в функции «_D4arsd3dds__T15ddsLoadFromFileZQsFS3std5stdio4FileZCQBz5color14TrueColorImage»:
app.d:(.text._D4arsd3dds__T15ddsLoadFromFileZQsFS3std5stdio4FileZCQBz5color14TrueColorImage[_D4arsd3dds__T15ddsLoadFromFileZQsFS3std5stdio4FileZCQBz5color14TrueColorImage]+0x213): undefined reference «_D4arsd3dds17ddsLoadFromMemoryFAxvZCQBi5color14TrueColorImage»
collect2: error: ld execution ended with return code 1
Error: linker exited with status 1
April 27

On Wednesday, 27 April 2022 at 07:42:31 UTC, Alexander Zhirov wrote:

>
~/programming/d/pic $ dmd app.d

Try passing the -i flag: dmd -i app.d. This way, imported modules are actually compiled and linked too. Currently it looks like you import arsd, but then don't link the library, so it complains about undefined references to functions in arsd.