Hello, I've been working on a program to separate the 6 images in a standard 4 by 3 cubemap. I've got nearly everything worked out, but after it finishes running and I open the images up, they don't seamlessly line up. Any ideas why?
Rem Project: Cube Divider
Rem Created: 4/25/2009 7:00:35 PM
Rem ***** Main Source File *****
sync on
sync rate 0
rem set starting image number
begin$=get dir$()
start:
image_number=1
b=0
q=0
cd begin$
rem choose best display
perform checklist for display modes
for c=1 to checklist quantity()
width=checklist value a(c)
height=checklist value b(c)
depth=checklist value c(c)
next c
if check display mode(width,height,32)=1
set display mode width,height,32
else
set display mode width,height,depth
endif
cls
set cursor 0,0
rem show available image files
print "Available image files:"
find first
repeat
b=b+1
a$=get file name$()
if right$(a$,3)="jpg" or right$(a$,3)="bmp" or right$(a$,3)="tga" or right$(a$,3)="dds" or right$(a$,3)="dib" or right$(a$,3)="png"
print a$
q=q+1
endif
find next
until get file type()=-1
rem get the y coordinate of the input text below
h=(q*15)+20
set text opaque
print
sync
set cursor 0,h
input "Image name> ",image_name$
rem make sure that the file does indeed exist
check:
find first
repeat
a$=get file name$()
if image_name$=a$
rem if file exists, jump to good
goto good
endif
find next
until get file type()=-1
rem if it doesn't exist, redo and check again
set cursor 0,h
r$="Image does not exist. Please reenter image name> "
print r$
set cursor 390,h
input image_name$
goto check
good:
rem create the name of the saved image file
b=len(image_name$)-4
save_name$=left$(image_name$,b)
cls
sync
load image image_name$,image_number,1
rem get square width and height
imagex=image width(1)/4
imagey=image height(1)/3
create bitmap 1,imagex,imagey
rem get working directory
dir$=get dir$()
t=len(image_name$)
rem make folder name
folder_name$=left$(image_name$,t-4)
rem make skycube folder
if path exist("C:\Users\"+get user name$()+"\Pictures\Skycubes\")=0
make directory "C:\Users\"+get user name$()+"\Pictures\Skycubes"
endif
rem make folder where separated images will go
make directory "C:\Users\"+get user name$()+"\Pictures\Skycubes\"+folder_name$+""
move file ""+dir$+"\"+image_name$+"","C:\Users\"+get user name$()+"\Pictures\Skycubes\"+folder_name$+"\"+image_name$+""
set dir "C:\Users\"+get user name$()+"\Pictures\Skycubes\"+folder_name$+""
rem top
paste image 1,-imagex,0
get image image_number+1,0,0,imagex,imagey,1
a$=""+save_name$+"_T.jpg"
save image a$,image_number+1
delete image image_number+1
rem west
paste image 1,0,-imagey
get image image_number+2,0,0,imagex,imagey,1
b$=""+save_name$+"_W.jpg"
save image b$,image_number+2
delete image image_number+2
rem north
paste image 1,-imagex,-imagey
get image image_number+3,0,0,imagex,imagey,1
c$=""+save_name$+"_N.jpg"
save image c$,image_number+3
delete image image_number+3
rem east
paste image 1,-imagex*2,-imagey
get image image_number+4,0,0,imagex,imagey,1
d$=""+save_name$+"_E.jpg"
save image d$,image_number+4
delete image image_number+4
rem south
paste image 1,-imagex*3,-imagey
get image image_number+5,0,0,imagex,imagey,1
e$=""+save_name$+"_S.jpg"
save image e$,image_number+5
delete image image_number+5
rem bottom
paste image 1,-imagex,-imagey*2
get image image_number+6,0,0,imagex,imagey,1
f$=""+save_name$+"_B.jpg"
save image f$,image_number+6
delete image image_number+6
delete image image_number
delete bitmap 1
cls
print "Complete."
print "Your separated and original cubemap can be found at: C:\Users\"+get user name$()+"\Pictures\Skycubes\"+folder_name$+""
print "Press any key to start over."
sync
wait key
cls
sync
goto start
I've attached the image that I've been using to experiment on. Thanks.
EDIT: Sorry, forgot to mention that you have to have the image in the same folder as the program for it to be able to see it.
EDIT2: Program fixed. Thanks, Sixty Squares.
EDIT3: Update, added repeatability to it. Working on finding ONLY usable images.
EDIT4: Repeatability added. Works with images of any size now. Thanks to Sixty Squares for all the help!