I've had this issue before, it seems that if the memblock gets too big then it fills up with junk values.
When I ran you code but had the width and height set to 10 there was no problem with the image. Obviously this isn't a solution but hopefully give some background.
What I did was set all the pixel values - red, green, blue and alpha - to zero then filled the memblock with the values I wanted. This can be done with a for-to-next loop, which I've added to your function.
SetVirtualResolution(500,500)
SetWindowSize(500,500,0)
m_Id = Create_Memblock()
ifm_Id = CreateImageFromMemblock(m_Id)
s_Id = CreateSprite(ifm_Id)
// make the sprite bigger so we can see the coloured pixel
SetSpriteScale(ifm_Id,10,10)
do
SetSpritePosition(s_Id, 0, 0)
Sync()
loop
function Create_Memblock()
image_header as integer = 12
colour_depth as integer = 32
bytes_per_pixel as integer = 4
width as integer = 30
height as integer = 30
image_size as integer
image_size = width * height * bytes_per_pixel + image_header
memblock_id = CreateMemblock(image_size)
SetMemblockInt(memblock_id, 0, width)
SetMemblockInt(memblock_id, 4, height)
SetMemblockInt(memblock_id, 8, colour_depth)
// set all the pixel values to zero
for i = 12 to image_size step 4
setMemblockByte(memblock_id,i,0)
setMemblockByte(memblock_id,i+1,0)
setMemblockByte(memblock_id,i+2,0)
setMemblockByte(memblock_id,i+3,255)
next
SetMemblockByte(memblock_id, 12, random(0,255))
SetMemblockByte(memblock_id, 13, random(0,255))
SetMemblockByte(memblock_id, 14, random(0,255))
SetMemblockByte(memblock_id, 15, 255)
endfunction memblock_id
Hope this helps.