I added image as file and set type as resource (see screenshot) How do I pull it out as byte array without using resx files, etc?
If you dont use the image directly (i.e: from a control if your project is a Windows App) then you could:
1- change the file extension (i.e: *.jpg.data)
2- add the "image" to a resource file RESX
3- access the byte array using: Resources.PathToImages.ResxFileName.ImageName
Note: if you add the image with the extension unchanged the RESX compiler creates a Bitmap property instead of a byte[] property.
The process is described in How to embed and access resources by using Visual C#.
Essentially it requires use of reflection, using the Assembly
class.
Stream imageStream =
currentAssembly.GetManifestResourceStream("Resources.logo_foot.png");
See How to convert an Stream into a byte[] in C#? for details of how to get a byte[]
from a Stream
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With