Need help with some code
I'm trying to draw an external image and whenever I try to use it in a function I get this error: "Cannot convert system.drawing.image to string"
First I loaded the image:
private Image bun;
Image bun = Image.FromFile("scripts\HotDog\bun.png");
I've been trying to fix it for 3 hours straight, this is the last thing I tried:
byte imageToByteArray(System.Drawing.Image img)
MemoryStream memoryStream = new MemoryStream();
Function.Call(Hash.DRAW_SPRITE, Convert.ToBase64String(imageToByteArray(bun)), 0.2, 0.1, 0.1, 0.09, 0.0, 255, 255, 255, 255);
Use UI.DrawTexture, pass in the path of the image. Not on my PC right now so I can't share actual code. But there are examples in gtaforums and possibly in these forums as well.
texture = AppDomain.CurrentDomain.BaseDirectory + "\HotDog\nuts.png";
Point posImage = new Point(618, 330);
Size sizeImage = new Size(1000, 1000);
UI.DrawTexture(texture, 100, 10, 100, posImage, sizeImage);
tried this, won't work.
Image bun = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\HotDog\nuts.png");
UI.DrawTexture(AppDomain.CurrentDomain.BaseDirectory + "\HotDog\nuts.png", 100, 10, 100, posImage, sizeImage);
Function.Call(Hash.DRAW_SPRITE, AppDomain.CurrentDomain.BaseDirectory + "\HotDog\nuts.png", 0.2, 0.1, 0.1, 0.09, 0.0, 255, 255, 255, 255);
Am I giving the wrong directory? My .png is located inside scripts\HotDog\nuts.png
Is the image perhaps too small?
float ar = Function.Call<float>(Hash._GET_SCREEN_ASPECT_RATIO, true); UI.DrawTexture(@".\scripts\ActionWheel\wheel2.png", 0, 0, 100, new Point(UI.WIDTH / 2, UI.HEIGHT / 2), new PointF(0.5f, 0.5f), new Size(Convert.ToInt32(300f * (16f/9f)), 300), 0f, Color.FromArgb(150, 255, 255, 255), ar);
This code was shared by user MaxShadow, it displays an image in the center of the screen. To adjust the position and size, just change the 5th and 7th parameters. See this link to see what scripthookvdotnet does internally, it will help you understand how to adjust the position and size parameters.
Worked! Thanks stillhere you're the best! I'll give you and MaxShadow credits when I release the mod!