forum.boolean.name

forum.boolean.name (http://forum.boolean.name/index.php)
-   2D-программирование (http://forum.boolean.name/forumdisplay.php?f=109)
-   -   создание стрип картинок (http://forum.boolean.name/showthread.php?t=3797)

jimon 02.07.2007 18:33

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

Код:


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. надо бы дописать ету программу - добавить интерфейс :)


Часовой пояс GMT +4, время: 01:22.

vBulletin® Version 3.6.5.
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Перевод: zCarot