0
나는 스플래시 스크린 프로그램을 만들었습니다.이 프로그램은 폴더에서 그림을로드하고 간격을두고 이미지를 변경하므로 효과가 심장을 뛰게합니다. 하지만 폴더 에서이 이미지를로드하고 싶지만 어셈블리의 리소스. 이 비트 맵 배열을로드하는 방법을 모릅니다. 나를 도와 줄 수 있습니까? 이건 내 코드입니다 :C# 리소스에서 비트 맵 배열 얻기
private static string imagefile;
private static int selected = 0;
private static int begin;
private static int end = 0;
// private static string path = SplashDemo.Properties.Resources.ResourceManager.GetStream();
private static string path = "C:/Users/Desktop/Desktop/New folder";
private static string[] folderFile = null;
[STAThread ()]
private static void Main ()
{
Splasher.Splash = new SplashScreen ();
Splasher.ShowSplash ();
// TIMER
System.Timers.Timer timer = new System.Timers.Timer();
timer.Interval = 50;
timer.Enabled = true;
timer.AutoReset = true;
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Tick);
// END TIMER
// GET ASSEMBLY FILS
System.Reflection.Assembly thisExe;
thisExe = System.Reflection.Assembly.GetExecutingAssembly();
string[] resources = thisExe.GetManifestResourceNames();
// Bitmap[] image = new Bitmap[string];
// Bitmap[] imagew = new Bitmap[10];
// Bitmap image = new Bitmap(file);
// string[] embeddedResources = Assembly.GetExecutingAssembly().GetManifestResourceNames();
// END GET ASSEMBLY FILS
// GET DIRECTORY FILES
string[] part1 = null, part2 = null, part3 = null;
part1 = Directory.GetFiles(path, "*.png");
part2 = Directory.GetFiles(path, "*.jpeg");
part3 = Directory.GetFiles(path, "*.bmp");
folderFile = new string[part1.Length + part2.Length + part3.Length];
Array.Copy(part1, 0, folderFile, 0, part1.Length);
Array.Copy(part2, 0, folderFile, part1.Length, part2.Length);
Array.Copy(part3, 0, folderFile, part1.Length + part2.Length, part3.Length);
bool beating = true;
selected = 0;
begin = 0;
end = folderFile.Length;
while (beating == true)
{
ImageListener.Instance.ReceiveImage(string.Format(@"{0}", imagefile));
}
}
public static void timer_Tick(object sender, EventArgs e)
{
ChangeImage();
}
public static void ChangeImage()
{
if (selected == folderFile.Length - 1)
{
selected = 0;
imagefile = (folderFile[selected]);
}
else
{
selected = selected + 1;
imagefile = (folderFile[selected]);
}
}
감사하지만 코드가 "MyAssemblyName.Resources.MypictureName.jpg"이므로 "Resources"를 추가했습니다. – user1493114
좋아요. 답변을 업데이트했습니다. 그게 지금 당신을 위해 일하고 있습니까? 그렇다면 대답을 수락하는 것을 잊지 마십시오. –
완료. 다시 한 번 감사드립니다 :) – user1493114