Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
GeneralRe: Dgv vertically its possible? Pin
OriginalGriff30-Dec-18 5:17
mveOriginalGriff30-Dec-18 5:17 
QuestionSearch file remotely C# Pin
Member 1410307028-Dec-18 21:55
Member 1410307028-Dec-18 21:55 
AnswerRe: Search file remotely C# Pin
pkfox28-Dec-18 22:33
professionalpkfox28-Dec-18 22:33 
GeneralRe: Search file remotely C# Pin
#realJSOP30-Dec-18 2:53
mve#realJSOP30-Dec-18 2:53 
AnswerRe: Search file remotely C# Pin
BillWoodruff29-Dec-18 1:05
professionalBillWoodruff29-Dec-18 1:05 
AnswerRe: Search file remotely C# Pin
#realJSOP30-Dec-18 2:56
mve#realJSOP30-Dec-18 2:56 
AnswerRe: Search file remotely C# Pin
Gerry Schmitz30-Dec-18 8:28
mveGerry Schmitz30-Dec-18 8:28 
QuestionUsing A FileStream As A Texture? Pin
SawmillTurtle26-Dec-18 17:54
SawmillTurtle26-Dec-18 17:54 
I'm still learning C# and I have a long way to go. I wanted to dive into MonoGame because tinkering with game design has been a hobby of mine since I started learning QBasic at the age of 14. I don't want to use their Content Pipeline to load content, because I'd like to figure out how to load custom resources as needed. Someone on Stack Overflow commented HERE that they use FileStreams to load textures directly. I set about trying to figure out how to do that, and I've gotten this far:

C#
FileStream fs = new FileStream("stars.jpg", FileMode.Open);
byte[] readString = new byte[fs.Length];
fs.Read(readString, 0, (int)fs.Length);


I have no idea if that code even works, because I haven't gotten to a point where running it would yield any visible results. It seems sound, so once I get the file data in the readString array, I need a way to use it as texture data. I tried casting:

C#
object o = (object)readString;
background = (Texture2D)o;


I already know that isn't going to work. I don't even need to run it to figure that one out. I read a little in the MonoGame Reference and thought about using Texture2D.SetData as shown HERE, but I'm not sure how to proceed or even if I'm headed in the right direction. The syntax they provide doesn't really clarify anything.


C#
public void SetData<T>(
    T[] data
) where T : ValueType, new()


There's an array here, but I'm not sure what it's asking for. Can I provide SetData with the byte array?

C#
background.SetData(readString);


Your help would be most appreciated, and it would go a long way towards helping me advance in my learning.

Thanks. Smile | :)

-Turtle

modified 27-Dec-18 0:00am.

AnswerRe: Using A FileStream As A Texture? Pin
Richard MacCutchan26-Dec-18 22:31
mveRichard MacCutchan26-Dec-18 22:31 
Questionhow to extract text from text file and store it in a variable using c# Pin
Syed_Owais24-Dec-18 20:54
professionalSyed_Owais24-Dec-18 20:54 
AnswerRe: how to extract text from text file and store it in a variable using c# Pin
OriginalGriff24-Dec-18 21:04
mveOriginalGriff24-Dec-18 21:04 
GeneralRe: how to extract text from text file and store it in a variable using c# Pin
Dave Kreskowiak25-Dec-18 4:46
mveDave Kreskowiak25-Dec-18 4:46 
GeneralRe: how to extract text from text file and store it in a variable using c# Pin
OriginalGriff25-Dec-18 5:00
mveOriginalGriff25-Dec-18 5:00 
AnswerRe: how to extract text from text file and store it in a variable using c# Pin
Dave Kreskowiak25-Dec-18 4:46
mveDave Kreskowiak25-Dec-18 4:46 
GeneralRe: how to extract text from text file and store it in a variable using c# Pin
BillWoodruff27-Dec-18 16:17
professionalBillWoodruff27-Dec-18 16:17 
GeneralRe: how to extract text from text file and store it in a variable using c# Pin
Dave Kreskowiak27-Dec-18 17:45
mveDave Kreskowiak27-Dec-18 17:45 
AnswerRe: how to extract text from text file and store it in a variable using c# Pin
SawmillTurtle25-Dec-18 22:06
SawmillTurtle25-Dec-18 22:06 
GeneralRe: how to extract text from text file and store it in a variable using c# Pin
BillWoodruff27-Dec-18 16:19
professionalBillWoodruff27-Dec-18 16:19 
GeneralRe: how to extract text from text file and store it in a variable using c# Pin
Richard MacCutchan27-Dec-18 22:25
mveRichard MacCutchan27-Dec-18 22:25 
AnswerRe: how to extract text from text file and store it in a variable using c# Pin
Gerry Schmitz28-Dec-18 9:08
mveGerry Schmitz28-Dec-18 9:08 
QuestionRendering Kleinian group fractals Pin
Member 1157700824-Dec-18 19:19
Member 1157700824-Dec-18 19:19 
AnswerRe: Rendering Kleinian group fractals Pin
Dave Kreskowiak25-Dec-18 4:43
mveDave Kreskowiak25-Dec-18 4:43 
GeneralRe: Rendering Kleinian group fractals Pin
BillWoodruff26-Dec-18 7:43
professionalBillWoodruff26-Dec-18 7:43 
GeneralRe: Rendering Kleinian group fractals Pin
Dave Kreskowiak26-Dec-18 7:58
mveDave Kreskowiak26-Dec-18 7:58 
GeneralRe: Rendering Kleinian group fractals Pin
BillWoodruff27-Dec-18 16:25
professionalBillWoodruff27-Dec-18 16:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.