All perfect praise be to Allaah, the Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
Looking at obscene pictures does not invalidate one's fasting (in principle), nor is his reward decreased by the sudden glance (at an obscene picture) after which he turns away his eyes, nor is he sinful by this glance. When Jareer asked the Prophet, sallallaahu ‘alayhi wa sallam, about the sudden glance (on the face of a non-Mahram woman), he said: "Turn away your gaze." [Muslim and Abu Daawood] The Prophet, sallallaahu ‘alayhi wa sallam, also told ‘Ali : "Do not let a second look follow the first, as the first look is for you, but the second is not for you." [Ahmad and At-Tirmithi] This means that the first unintentional glance does not count as a bad deed, whereas the second one counts because it is done on purpose. It should be noted that although misdeeds do not invalidate one's fasting, they may decrease its reward or wipe it out entirely. The Prophet, sallallaahu ‘alayhi wa sallam, said: "Perhaps a man takes from his fasting nothing except hunger and from his voluntary prayer at night nothing except wakefulness." [Ahmad and Ibn Maajah (this is Ibn Majaah's wording)]
Therefore, a Muslim should guard his fasting by refraining from prohibited looks and misdeeds in general. Misdeeds are evil and dangerous. We advise you to utilize the favor of having leisure time in what would benefit you in this life and in the Hereafter so that you would not be wasting it. The Prophet, sallallaahu ‘alayhi wa sallam, said: "There are two blessings which many people waste: health and free time." [Al-Bukhari and others]
Allaah Knows best.