All Answers

All Answers » Re: How to put image (byte) in Custom Wallpaper. » Comments for "Re: How to put image (byte) in Custom Wallpaper."
    • Guest
    • Feb 18, 2021 - 2:50 pm
    Yes, the image shows in the picturebox… But after i tried your code it occurs an exception.. i will send it, the first thing is in portuguese but here is the translation: “the object reference was not defined with an instance of an object. in” Check the image! https://prnt.sc/zzmswb
  • Frank (ITG)
    Are you reading more than 1 image from the database? If yes, your array definition looks wrong to me, it only allows 1 entry: Dim imageListEntries As ImageListEntry() = New ImageListEntry(1) {} Best regards, Frank
    • Guest
    • Feb 18, 2021 - 4:29 pm
    It only have one image bro.. I dont know what is wrong here…
    • Guest
    • Feb 18, 2021 - 4:31 pm
    I will send an image, please check this out, it’s the code that im using, and i only have one image, and the picturebox shows up the image. https://prnt.sc/1001549
    • Guest
    • Feb 18, 2021 - 4:35 pm
    Look, the black background is the CustomWallpaper Control wich doesn’t load correctly, and then u can see the picturebox that loads the image sucessfully… https://prnt.sc/10017qb
  • Luca
    • Luca
    • Feb 18, 2021 - 5:16 pm
    When you use a stream the Position changes. So the second time it’s invalid since it’s a the end of stream. Second if the image is a jpg in .NET it uses interlaced rendering (which is a jpeg thing) so if you create it from a stream it keeps the stream open and when you use the stream again it moves to the end invalidating the image (if you enable logging in web,config you see the exceptions). In that case you either keep leave the stream alone (use it only once) or use this instead new Bitmap(Image.FromStream(stream)). This is a common technique when loading jpegs from a stream, So, basically, the second time you use the stream breaks the first image. If it still fails for you attach a test case with an image file that show how it fails. I just tried the sample that Frank attached and it works without issues with pngs.
    • Guest
    • Feb 18, 2021 - 5:17 pm
    So, this one is using basically your code, and the picturebox works, but not the CustomWallpaper.. Check this out, it’s more organizated. https://prnt.sc/100218q
  • Luca
    • Luca
    • Feb 18, 2021 - 5:19 pm
    It works well unless it’s a jpeg because of the issue I explained above.