Image split into alot of new images

ThuGie.NL - Webmaster
Joined
Apr 16, 2006
Messages
607
Reaction score
55
Location
Netherlands
Hi i'm searching for a code that can create pieces of 32x32 of a 512x15904 image
like 0x0.png 1x0.png to 14x0.png and then 0x1.png etc
but the orignal image got transparent and i dont want to lose that
with my current code i do lose that and i havent found a way around that :(
anybody able to help me with this problem ?
i tried a png plugin although the images ended up corrupted not because of my coding because even the 3 samples provided where corrupted

Thanks and hope somebody can help me :).
the code is in RealBasic by the way
a program or php code would also help.
Code:
Sub Action()
  dim f as folderitem
  dim i as integer
  dim a as integer
  a =0
  do until a = 15
    i=0
    Do Until i = 497
      f = New folderItem("temp/" + str(a) + "x" + str(i) + ".bmp")
      f.SaveAsPicture playfield.NewSprite(readtiles(i,a),a*add,i*add).image
      i=i+1
    Loop
    a=a+1
  loop

End Sub

Function ReadTiles(Row as integer,Column as integer) As Picture
  Dim pic as Picture
  Pic = NewPicture(add,add,Screen(0).Depth)
  Pic.Graphics.DrawPicture(AllTiles,0,0,add,add,Column*add,Row*add,add,add)
  Return Pic
End Function
 
Allocate a buffer big enough to hold your image (in this case 32Mb), and decompress the PNG into it. You'll need to open 16 files at a time (512/32) and write consecutively 32 pixels to each, for 32 scanlines. Close all 16 files, create another 16, and repeat.

After that, or alternatively at the end of each 32 scanline block, PNG all the raw image data to create the final output.
 
uhm if i'm correct bmp files dont have any transparent options..
at least not in realbasic..
i can save it as bmp or jpg jpg is just ugly and cant choose the quality
and with bmp the same although bmp aint got any quality loss.
as the code shows
only thing i can do give it the image source and let it save it
i tried a png plugin but it seems the png plugins dont work not even the examples :(.
well they work the images are just screwed..
i tried using php to make the images transparent 1 by 1 but
it seems php doesnt load bmp's..
i used diffrent modules all errored or resulted in a strange image.

so if you could provide a sample of any kind thats something that would help me.
and saying "Use a 32-bit bitmap, obviously (ARGB). That extra byte is the alpha channel."
wont do any good because obviously i'm bad with images and thats kinda the reason i'm posting this question here correct?
 
sage

uhm if i'm correct bmp files dont have any transparent options..
So what? Why are you using the .BMP format anyway? I already gave you a hint here, you must've missed it:
username1 said:
After that, or alternatively at the end of each 32 scanline block, PNG all the raw image data to create the final output.
 
Back