question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Load image from EmbeddedResource

See original GitHub issue

Before submitting a new issue, please verify and check:

  • The issue is specific to Raylib-cs and not raylib
  • I checked there is no similar issue already reported
  • My code has no errors or misuse of Raylib-cs

Issue description

I would like to be able to load an image file using embedded resources and convert this to a Raylib_cs.Image/Texture

Environment

Code example

My current code:

var myStream = Program.game.GetType().Assembly.GetManifestResourceStream(path);
var image = System.Drawing.Image.FromStream(myStream);

return Raylib.LoadTextureFromImage(image);

Throws the error:

error CS1503: Argument 1: cannot convert from 'System.Drawing.Image' to 'Raylib_cs.Image'

There may already be a way to do this, but I couldn’t find one in the examples or looking at the lib’s code. The Go raylib library provides a NewImageFromImage function that converts a native go Image into a Raylib one, so something like that would probably do

Thanks

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
9ParsonsBcommented, Aug 22, 2022

You could always combine the files after building (e.g. copy /b Game.exe + Resources.rres GameWithResources.exe) and then split them up again at runtime by looking for the rres Magic Bytes (HEX: 72 72 65 73).

I am currently developing an rres parser for use with Raylib-cs, so I will take this use-case under consideration

0reactions
drum445commented, Dec 27, 2022

@JupiterRider cheers for that, it seems to be working well.

Many thanks 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Load image from resources area of project in C# - ...
myimage. This will get the image via a generated C# property. If you just set the image as Embedded Resource you can get...
Read more >
Embedded Image Resources
Add Image Resource · In Visual Studio, click the Project menu, and select Add Existing Item. · In the Solution Explorer window, right-click...
Read more >
How to read a embedded resource image in C# and VB.NET
ByAdministrator. To read a embedded resource image in C# and VB.NET you can use the following snippet.
Read more >
How to load embebbed resource image in WPF?
To embed an image as a resource, add it to your project and set its Build Action to Resource. You can access this...
Read more >
How to load image with embedded and from URL in ...
This article explains to load images from URL and embedded resource in the SfRichTextEditor. Step 1: Create a SfRichTextEditor sample with all the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found