Just changing the rawimage material to white color not make it bright enough.
So I added to the rawimage this script after added reference to the visual studio of the system.drawing also added copied the system.drawing to the Assets/Plugins folder.
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using UnityEngine;
using UnityEngine.UI;
public class MouseHover : MonoBehaviour
{
[Range(0, 500)]
public float bright;
private Bitmap myImage;
public void OnHover()
{
Debug.Log("Enter");
}
public void OnHoverExit()
{
Debug.Log("Exit");
}
private void BrightImage()
{
myImage = new Bitmap(GetComponent<UnityEngine.UI.Image>());
}
public static Bitmap AdjustBrightness(Bitmap Image, int Value)
{
Bitmap TempBitmap = Image;
Bitmap NewBitmap = new Bitmap(TempBitmap.Width, TempBitmap.Height);
System.Drawing.Graphics NewGraphics = System.Drawing.Graphics.FromImage(NewBitmap);
float FinalValue = (float)Value / 255.0f;
float[][] FloatColorMatrix ={
new float[] {1, 0, 0, 0, 0},
new float[] {0, 1, 0, 0, 0},
new float[] {0, 0, 1, 0, 0},
new float[] {0, 0, 0, 1, 0},
new float[] {FinalValue, FinalValue, FinalValue, 1, 1}
};
ColorMatrix NewColorMatrix = new ColorMatrix(FloatColorMatrix);
ImageAttributes Attributes = new ImageAttributes();
Attributes.SetColorMatrix(NewColorMatrix);
NewGraphics.DrawImage(TempBitmap, new Rectangle(0, 0, TempBitmap.Width, TempBitmap.Height), 0, 0, TempBitmap.Width, TempBitmap.Height, GraphicsUnit.Pixel, Attributes);
Attributes.Dispose();
NewGraphics.Dispose();
return NewBitmap;
}
}
I want to be able to use the bright variable to change the image brightness.
but getting error on the line :
myImage = new Bitmap(GetComponent<UnityEngine.UI.Image>());
Argument 1: cannot convert from âUnityEngine.UI.Imageâ to âstringâ
This is how the image looks like when the game is running in the rawimage :
The left image is too dark :
The problem is that Iâm taking screenshots from the game so the problem is not light problem or something in the scene the problem is in the image on the hard disk because when I take screenshots from the game in some cases and places the light/s in the game is not the same so the image looks like too dark but the image is fine.
That is why I want to be able to change the image brightness and not to add lights or other stuff.
Maybe it will help too so this is the script Iâm using to take screenshots from the game and save them as images on the hard disk :
using UnityEngine;
using System.Collections;
using System.IO;
public class HiResScreenshots : MonoBehaviour
{
public int resWidth = 1920;
public int resHeight = 1080;
public SaveLoad saveLoad;
public static string ScreenShotName(int width, int height)
{
return string.Format("{0}/screenshots/screen_{1}x{2}_{3}.png",
Application.dataPath,
width, height,
System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"));
}
void Update()
{
if (Input.GetKeyDown("k"))
{
var filename = ScreenShotName(resWidth, resHeight);
var directory = Path.GetDirectoryName(filename);
Directory.CreateDirectory(directory);
ScreenCapture.CaptureScreenshot(filename);
StartCoroutine(saveLoad.SaveWithTime(directory,Path.GetFileNameWithoutExtension(filename) + ".savegame.txt"));
}
}
}