解决  我试图用石灰间隔选项制作图像幻灯片展示

jnkukka

成员
加入
3月26,2021
消息
5
编程经验
Beginner
我正在尝试在我的图形布局中使用石灰间隔选项进行图像幻灯片。但是图像幻灯片显示在图像序列中的工作。你能帮助我。我使用MediaLooks MPLatform SDK。
thi-code-jpg.1477
 

附件

  • thi是code.jpg.
    thi是code.jpg.
    231.1 KB · Views: 16

跳伞运动员

工作人员
加入
2019年4月6日
消息
2,816
地点
切萨皮克,va.
编程经验
10+
请不要将代码发布为屏幕截图。在代码标记中发布代码。

从我可以从屏幕截图中读取的一点,看起来你在按钮上的所有图像上迭代,而不是每次定时器滴答事件火灾时递增福彩12选5走势图图像。
 

jnkukka

成员
加入
3月26,2021
消息
5
编程经验
Beginner
请不要将代码发布为屏幕截图。在代码标记中发布代码。

从我可以从屏幕截图中读取的一点,看起来你在按钮上的所有图像上迭代,而不是每次定时器滴答事件火灾时递增福彩12选5走势图图像。
我更新我的代码
C#:
// Sets up an image object to be displayed.
            if (MyImage != null)
            {
                MyImage.Dispose();
            }
            MyImage = new Bitmap(images[imageIX]);

            // Stretches the image to fit the pictureBox.
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox1.Image = (Image)MyImage;
            imageIX++;
            if (imageIX > 10)
                timer1.Stop();
 

附件

  • 更新Timer.jpg.
    更新Timer.jpg.
    212 KB · Views: 1

跳伞运动员

工作人员
加入
2019年4月6日
消息
2,816
地点
切萨皮克,va.
编程经验
10+
好的。代码现在正常工作也是如此?如果没有,你看到了什么行为?你做了什么来试图弄清楚它为什么无法正常工作?
 

跳伞运动员

工作人员
加入
2019年4月6日
消息
2,816
地点
切萨皮克,va.
编程经验
10+
你做了什么来试图弄清楚它为什么无法正常工作?
 

跳伞运动员

工作人员
加入
2019年4月6日
消息
2,816
地点
切萨皮克,va.
编程经验
10+
From what I can try to read from that newest screenshot, it looks like you have a null exception error due to images array being null.

如果您处于异常,则无需屏幕截图。您只需单击“"Copy details"在这里的信息中的例外和粘贴上的链接在此处的代码标记。
 

jnkukka

成员
加入
3月26,2021
消息
5
编程经验
Beginner
From what I can try to read from that newest screenshot, it looks like you have a null exception error due to images array being null.

如果您处于异常,则无需屏幕截图。您只需单击“"Copy details"在这里的信息中的例外和粘贴上的链接在此处的代码标记。
system.nullreferenceException.
HResult=0x80004003
消息=对象引用未设置为对象的实例。
source = cgeditor_winforms.
StackTrace:
在CITGITONTER_WINFORMS.MAINWINDOW.TIMER1_TICK(Object Sender,Eventargs E)中的E:\ Test Work \ Cgeditor_Winforms \ MainWindow.cs:Line 1000
在system.windows.forms.timer.ontick(Eventargs E)
在system.Windows.Forms.Timer.TimernativeWindow.wndproc(消息& m)
在system.windows.forms.nativewindow.debuggablecallback(Intptr hwnd,int32 msg,intptr wparam,intptr lparam)
在system.windows.forms.unsafenativemethods.dispatchmessagew(msg& msg)
在system.windows.forms.application.componentmanager.system.windows.forms.unsafenativemethods.imsocomponentmanager.fpushmessageloop(intptr dwcomponentid,int32原因,Int32 pvloopdata)
在System.Windows.Forms.Application.ThreadContext.RunMessageLoopinner(Int32原因,ApplicationContext上下文)
在system.windows.forms.application.threadcontext.runmessageloop(int32原因,applicationcontext上下文)
在system.windows.forms.form.showdialog(IWIN32Window所有者)
在PlayListsample.Form1.CGeditorButton_Click(Object Sender,Eventargs E)中的E:\ Test Work \ PlayList Sample \ Form1.cs:第295行
在system.windows.forms.control.onclick(eventargs e)
在system.windows.forms.button.onclick(eventargs e)
在system.windows.forms.button.onmouseUp(MouseEventargs Mevent)
在system.windows.forms.control.wmmeouseup(消息&M,MouseButtons按钮,INT32点击)
在system.windows.forms.control.wndproc(消息& m)
在system.windows.forms.buttonbase.wndproc(消息& m)
在system.windows.forms.button.wndproc(消息& m)
在system.windows.forms.nativewindow.debuggablecallback(Intptr hwnd,int32 msg,intptr wparam,intptr lparam)
在system.windows.forms.unsafenativemethods.dispatchmessagew(msg& msg)
在system.windows.forms.application.componentmanager.system.windows.forms.unsafenativemethods.imsocomponentmanager.fpushmessageloop(intptr dwcomponentid,int32原因,Int32 pvloopdata)
在System.Windows.Forms.Application.ThreadContext.RunMessageLoopinner(Int32原因,ApplicationContext上下文)
在system.windows.forms.application.threadcontext.runmessageloop(int32原因,applicationcontext上下文)
在PlayListsample.program.main()在E:\ Test Work \ PlayList Sample \ Program.CS:Line 17中
 

jmplhinney.

C#论坛主持人
工作人员
加入
2011年4月23日
消息
3,692
地点
悉尼,澳大利亚
编程经验
10+
The error message is telling you that you're getting a NullReferenceException and where it is thrown. Have you searched the web to find out what exactly that exception means? Assuming you do know what it means, have you debugged the code and examined the references on that line to see which one(s) is null? There aren't many options.

初学者经常思考"我不知道该怎么做,所以我什么都不做". It is very rare that there really is nothing you can do. You have keywords all around you - most notably NullReferenceException in this case - so you ALWAYS have the option of searching the web using those keywords to try to get more useful information. If you knew what a NullReferenceException was then you'd have a much better chance of diagnosing it, so you should be trying to find out what it is.

那说, @skydiver has pretty much told you what the problem is. You appear to be trying to get an element from an array that doesn't exist. Have you checked whether images is null or not when the exception is thrown? If not, why not? If so, is it null? If it is then where exactly do you think it should been assigned a value? If there is no such line of code then the issue is obvious. If there is such a line then you need to debug your code. Place a breakpoint on that line to make sure that it's hit and, if it is, place a watch on the variable and step through the code to see when it get reset.
 

jnkukka

成员
加入
3月26,2021
消息
5
编程经验
Beginner
The error message is telling you that you're getting a NullReferenceException and where it is thrown. Have you searched the web to find out what exactly that exception means? Assuming you do know what it means, have you debugged the code and examined the references on that line to see which one(s) is null? There aren't many options.

初学者经常思考"我不知道该怎么做,所以我什么都不做". It is very rare that there really is nothing you can do. You have keywords all around you - most notably NullReferenceException in this case - so you ALWAYS have the option of searching the web using those keywords to try to get more useful information. If you knew what a NullReferenceException was then you'd have a much better chance of diagnosing it, so you should be trying to find out what it is.

那说, @skydiver has pretty much told you what the problem is. You appear to be trying to get an element from an array that doesn't exist. Have you checked whether images is null or not when the exception is thrown? If not, why not? If so, is it null? If it is then where exactly do you think it should been assigned a value? If there is no such line of code then the issue is obvious. If there is such a line then you need to debug your code. Place a breakpoint on that line to make sure that it's hit and, if it is, place a watch on the variable and step through the code to see when it get reset.
我正在改变我的代码:
 private void timer1_Tick(object sender, EventArgs e)
        {
            // Sets up an image object to be displayed.
            if (MyImage != null)
            {
                MyImage.Dispose();
            }
       
            try
            {
                MyImage = new Bitmap(images[imageIX]);
            }
            catch (Exception)
            {
               
            }

            // Stretches the image to fit the pictureBox.
           
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox1.Image = (Image)MyImage;
            imageIX++;
            if (imageIX > 10)
                timer1.Stop();

        }

现在它的工作
 

约翰

C#论坛主持人
工作人员
加入
2011年4月23日
消息
1,145
地点
挪威
编程经验
10+
你不需要在那里尝试捕获,你可以验证。如果阵列可以为null,您可以检查此功能,还可以检查索引是否有效。
发现条件不有效的原因也可能是福彩12选5走势图好主意,例如,如果没有数组,则为为什么定时器运行,或者为什么索引不有效?
 

跳伞运动员

工作人员
加入
2019年4月6日
消息
2,816
地点
切萨皮克,va.
编程经验
10+
Now its working
不幸的是,你把它解决了错误的方式。

您的修复就像将熔断器从发动机油变化灯中取出,因为油灯每隔几个月即可。正确的事情是改变你的油并重置光线。不正确的修复是只需忽略光线或将熔断器带出那种光。

在您的代码的情况下,由于您只是在吃异常,您现在正在使用配置的图像到达第21行。
 
最佳 底部