Показать сообщение отдельно
Старый 02.07.2007, 18:33   #1
jimon
 
Сообщений: n/a
создание стрип картинок

вот почему всегда нужный софт надо писать самому ...

Type StripCreator
	Field Images:TList
	Field StripImage:TImage
	Field Width#,Height#
	
	Method AddImageToStrip(FileName$)
		Local img:TImage = LoadImage(FileName$,DYNAMICIMAGE)
		Assert img,"can't load image " + FileName
		Images.AddLast(img)
	End Method
	
	Method GenerateStrip(FileName$)

		'calculate  strip size
		Local img:TImage
		For img = EachIn Images
			Width :+ img.width
			Height = Max(Height,img.height)
		Next
		
		'create strip image
		StripImage = CreateImage(Width,Height)
		
		'copy pixmaps
		Local StripPixMap:TPixmap = LockImage(StripImage)
		Local x#
		For img = EachIn Images
			Local ImgPix:TPixmap = LockImage(img)
			
			StripPixMap.Paste(ImgPix,x,0)
			x:+ImgPix.width
			
			UnlockImage(img)
		Next
		UnlockImage(StripImage)
		
		'save strip image
		SavePixmapPNG(StripImage.pixmaps[0],FileName,0)
	End Method
	
	Method Free()
		Images.Clear()
		Images = Null
		
		StripImage = Null
	End Method
	
	Function CreateStripCreator:StripCreator()
		Local st:StripCreator = New StripCreator
		st.Images = New TList
		st.StripImage = Null
		st.Width = 0
		st.Height = 0
		Return st
	End Function
End Type

Global st:StripCreator = StripCreator.CreateStripCreator()

st.AddImageToStrip("In/H_1.png")
st.AddImageToStrip("In/H_2.png")
st.AddImageToStrip("In/H_3.png")
st.AddImageToStrip("In/H_4.png")

st.GenerateStrip("test.png")

st.Free()
st = Null
юзайте на здоровье

ps. надо бы дописать ету программу - добавить интерфейс
 
Ответить с цитированием