开发者

embed image in usercontrol without resource file vb.net

开发者 https://www.devze.com 2023-02-19 03:57 出处:网络
I need to embed 4 small 16x16 images in a usercontrol, without imagelist, resource file etc. The reason 开发者_如何学运维is because i would be using this usercontrols in different projets, and i just

I need to embed 4 small 16x16 images in a usercontrol, without imagelist, resource file etc. The reason 开发者_如何学运维is because i would be using this usercontrols in different projets, and i just want to include the user control without much ado.

Is there anyway i can do this in code?


Sharing usercontrols as dll is the way to go, but if you prefer to include the usercontrol as source instead, you may include the images ... "hardcoded":

    Dim PictureStream As New IO.MemoryStream(New Byte() _
    {&H89, &H50, &H4E, &H47, &HD, &HA, &H1A, &HA, &H0, &H0, &H0, &HD, &H49, &H48, &H44, &H52, &H0, &H0, &H0, &H30, _
     &H0, &H0, &H0, &H30, &H4, &H3, &H0, &H0, &H0, &HA5, &H2C, &HE4, &HB4, &H0, &H0, &H0, &H1, &H73, &H52, &H47, _
     &H42, &H0, &HAE, &HCE, &H1C, &HE9, &H0, &H0, &H0, &H4, &H67, &H41, &H4D, &H41, &H0, &H0, &HB1, &H8F, &HB, &HFC, _
     &H61, &H5, &H0, &H0, &H0, &H20, &H63, &H48, &H52, &H4D, &H0, &H0, &H7A, &H26, &H0, &H0, &H80, &H84, &H0, &H0, _
     &HFA, &H0, &H0, &H0, &H80, &HE8, &H0, &H0, &H75, &H30, &H0, &H0, &HEA, &H60, &H0, &H0, &H3A, &H98, &H0, &H0, _
     &H17, &H70, &H9C, &HBA, &H51, &H3C, &H0, &H0, &H0, &H30, &H50, &H4C, &H54, &H45, &H0, &H0, &H0, &H80, &H0, &H0, _
     &H0, &H80, &H0, &H80, &H80, &H0, &H0, &H0, &H80, &H80, &H0, &H80, &H0, &H80, &H80, &H80, &H80, &H80, &HC0, &HC0, _
     &HC0, &HFF, &H0, &H0, &H0, &HFF, &H0, &HFF, &HFF, &H0, &H0, &H0, &HFF, &HFF, &H0, &HFF, &H0, &HFF, &HFF, &HFF, _
     &HFF, &HFF, &H7B, &H1F, &HB1, &HC4, &H0, &H0, &H0, &H9, &H70, &H48, &H59, &H73, &H0, &H0, &HE, &HC2, &H0, &H0, _
     &HE, &HC2, &H1, &H15, &H28, &H4A, &H80, &H0, &H0, &H1, &H8, &H49, &H44, &H41, &H54, &H38, &HCB, &H85, &H54, &H4B, _
     &H16, &HC4, &H20, &H8, &HE3, &H70, &H2C, &H39, &H36, &HCB, &H1C, &H6A, &H8, &HE0, &H67, &HDE, &H94, &H4E, &H17, &H16, _
     &HD, &H60, &H88, &HA2, &HA8, &HC2, &H55, &HD5, &H94, &HA3, &HBA, &H71, &HE4, &H8A, &H28, &H68, &HAA, &HD9, &HD7, &HCF, _
     &H55, &HCA, &H6A, &HD7, &H15, &H18, &HFF, &H0, &H2C, &H22, &HD1, &HB, &HE1, &H10, &H13, &H14, &HE0, &H1, &H69, &H7, _
     &H2A, &HFD, &H32, &H5E, &H3A, &H47, &H11, &H68, &H83, &H19, &HC5, &H9D, &H5B, &H61, &H91, &HE9, &H89, &H3B, &H23, &HDC, _
     &H7A, &HBD, &H10, &H30, &H93, &HCB, &H21, &H14, &H7F, &H6C, &H6A, &H76, &H0, &H18, &H60, &HBE, &H39, &H6F, &HC0, &H1C, _
     &H88, &H64, &H17, &HD0, &H35, &H5D, &H40, &HBA, &H6E, &H80, &H99, &H56, &HAE, &H2, &HAE, &H2D, &HEE, &H4D, &H64, &H89, _
     &H11, &H80, &H2F, &H80, &HC2, &HC8, &H12, &HC3, &H9C, &HEC, &HB1, &H85, &H11, &HEB, &HA2, &HC2, &H3B, &H3E, &HAC, &H62, _
     &H43, &HAB, &H5C, &H4F, &H46, &H96, &HCC, &H90, &H8, &H2B, &H4F, &H91, &H98, &H9E, &H18, &HCD, &HF4, &H95, &H12, &H3, _
     &H25, &H15, &HF2, &H8, &H32, &H44, &H36, &HD3, &H4, &HB0, &H39, &H13, &HA8, &H79, &H84, &H91, &H2, &HAD, &H6, &H6A, _
     &HCB, &H62, &H90, &H63, &H92, &H26, &H50, &H13, &H74, &H3E, &HE6, &HFA, &H13, &H31, &HEE, &H31, &HB3, &H1A, &HEB, &H78, _
     &HAE, &H7C, &HD4, &H6A, &H54, &HF7, &H9C, &H47, &H46, &H9C, &HF3, &H98, &H4F, &H70, &H3A, &HF3, &HF9, &H96, &H8C, &HF7, _
     &H6A, &HBC, &H89, &HFF, &HEE, &HEE, &HCF, &H6D, &HC7, &H63, &H7F, &HD8, &H7B, &H47, &H3D, &HF7, &HE0, &HD8, &HB5, &H2F, _
     &H7D, &H3E, &HBC, &HC, &HE3, &H5B, &H32, &HBF, &H3E, &H8B, &H8D, &HEF, &H31, &HE7, &H1F, &H67, &H2E, &H8, &HE7, &H2A, _
     &HE1, &HA1, &H7E, &H0, &H0, &H0, &H0, &H49, &H45, &H4E, &H44, &HAE, &H42, &H60, &H82})
    PictureBox1.Image = New Drawing.Bitmap(PictureStream)
    PictureStream = Nothing

(this is VB.Net, feel free to adapt to your language of choice)


If you add an ImageList (which would use a resx file under the controL) or a project level resource file, they do not create extra files and are compiled into your DLL.

0

精彩评论

暂无评论...
验证码 换一张
取 消