pallete in memory [solved]

New to FreeBASIC? Post your questions here.
Post Reply
honey data
Posts: 28
Joined: Feb 11, 2018 19:54
Location: portugal lisbon
Contact:

pallete in memory [solved]

Post by honey data »

I have a code that stretches an image, copies that image to a larger scale, the problem is that when copying the image I do not copy, the palette some way to copy the palette from one image to another? thank you





Code: Select all


sub stretch(image As Any Ptr,images As Any Ptr,w as integer,h as integer,s1 as integer,s2 as integer)
dim c1 as integer
dim c2 as integer
dim c3 as integer
dim c4 as integer
 Asm
    jmp asm2

    asm2:
          mov esi,[image]
          mov eax,32
          clc
         add esi,eax
         mov edi,[images]
         clc
         add edi,eax
        
        mov ax,[w]
       
        cmp ax,0
        jnz asm5
        jmp asm4
        asm5:
     
        
        mov ax,[h]
        mov [c1],ax
        cmp ax,0
        jnz asm3
        jmp asm4
        asm3:
        mov ebx,esi
       
         for1:
         
         mov dx,[s2]
     mov [c2],dx
        for2:
        mov esi,ebx
        mov dx,[w]
        mov [c3],dx
      for3:
      
      mov ax,[esi]
      mov dx,[s1]
      mov [c4],dx
      for4:
     
      mov [edi],ax
      inc edi
      inc edi
      mov dx,[c4]
      dec dx
      mov [c4],dx
      cmp dx,0
      jnz for4
      inc esi
      inc esi
      mov dx,[c3]
      dec dx
      mov [c3],dx
      cmp dx,0
      jnz for3
      mov dx,[c2]
      dec dx
      mov [c2],dx
      cmp dx,0
      jnz for2
      mov ebx,esi
      
           mov dx,[c1]
      dec dx
      mov [c1],dx
      cmp dx,0
      jnz for1
      
        asm4:
        
    End Asm

End sub

ScreenRes 640, 480, 16

Dim image As Any Ptr = ImageCreate( 64, 64, RGB(0,0,0) )
Dim images As Any Ptr = ImageCreate( 64*3, 64*3, RGB(255,0,0) )
cls
Dim w as integer=64
dim h as integer=64
dim s1 as integer=3
dim s2 as integer=3

line (0,0)-(640,480),rgb(255,255,255),bf

line (0,0)-(63,63),rgb(0,0,0),b
line (0,0)-(63,63),rgb(0,0,0)
line (0,63)-(63,0),rgb(0,0,0)
get (0,0)-(63,63),image

stretch image ,images,w,h,s1,s2
Put (0,160), images, PSet

'' Destroy the image.
ImageDestroy image
ImageDestroy images
sleep

Last edited by honey data on Feb 17, 2018 12:59, edited 3 times in total.
honey data
Posts: 28
Joined: Feb 11, 2018 19:54
Location: portugal lisbon
Contact:

Re: pallete in memory

Post by honey data »

check it the blue color is not in new palette, thanks, im want a fast sub ? some one?

Code: Select all


sub streatch(image As byte Ptr,images As byte Ptr,w as long,h as long,s1 as integer,s2 as integer)
dim x as long
dim y as long
dim ccolor as byte
dim ccolor2 as byte
dim xx as integer
dim yy as integer
dim pos1 as integer
dim pos2 as integer
dim pos3 as integer
pos1=32
pos3=pos1
pos2=pos1
for y=0 to h-1
for yy = 0 to s2-1
pos1=pos2
for x=0 to w-1
ccolor=image[pos1]
ccolor2=image[pos1+1]
for xx=0 to s1-1
images[pos3]=ccolor
images[pos3+1]=ccolor2
pos3=pos3+2
next xx
pos1=pos1+2
next x

next yy
pos2=pos1
next y


End sub

sub colorDep(image As byte Ptr,images As byte Ptr)
images[4]=image[4]
images[5]=image[5]
images[6]=image[6]
images[7]=image[7]
end sub 


ScreenRes 640, 480, 16
dim tim as integer =4
dim tim2 as integer =4
dim s as string ="im love marina."
dim x as integer
dim y as integer
dim xx as integer
dim yy as integer
x=(len(s)+1)*9
y=9
xx=x*tim
yy=y*tim2

Dim image As Any Ptr = ImageCreate(x,y,RGB(255,255,255),16 )
Dim images As Any Ptr = ImageCreate(xx,yy, RGB(255,255,255) ,16)
cls
Draw String image,(0,0),s ,rgb(0,0,255)
Put images,(0, 0), image, PSet

line (0,0)-(640,480),rgb(255,255,255),bf
Put (0, 0), image, PSet

streatch image,images,x,y,tim,tim2
colorDep image,images
Put (0, 160), images, PSet
'' Destroy the image.
ImageDestroy image
ImageDestroy images
sleep

Last edited by honey data on Feb 13, 2018 22:13, edited 1 time in total.
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: pallete in memory

Post by badidea »

Is ImageInfo not missing? https://www.freebasic.net/wiki/wikka.ph ... gImageInfo for properly accessing the pixels?

16-bit screen does not use palette, does it?

Also, this seems weird (ccolor2 is not used) :

Code: Select all

...
ccolor=image[pos1]
ccolor=image[pos1+1]
...
Use can also try 'MultiPut' for scaling: viewtopic.php?f=7&t=24479#p216898

Who is 'marina' :-)
honey data
Posts: 28
Joined: Feb 11, 2018 19:54
Location: portugal lisbon
Contact:

Re: pallete in memory

Post by honey data »

thanks, was this what I wanted, now in the examples, of the installation of freebasic freedos, there is a file \ examples \ gui \ cgui \ hello.bas, but I can not compile it, gives an error ld: - laleg and the error ld: -lcgui, but these Alegro libraries are in the directory inc, what is missing so you can compile the file, hello.bas thanks
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: pallete in memory

Post by badidea »

I can't help you with that. Getting FreeBasic to work with external libraries is often a 'Pain in the ass'.

Possible useful related discussions:
* Compiling CGUI for 64 bit
* Tutorial on how to link to / include library files in programs

Maybe better to start a new question / topic for this.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: pallete in memory

Post by jj2007 »

That asm code is very inefficient. Where did you find it?
honey data
Posts: 28
Joined: Feb 11, 2018 19:54
Location: portugal lisbon
Contact:

Re: pallete in memory

Post by honey data »

honey data
Posts: 28
Joined: Feb 11, 2018 19:54
Location: portugal lisbon
Contact:

Re: pallete in memory

Post by honey data »

honey data
Posts: 28
Joined: Feb 11, 2018 19:54
Location: portugal lisbon
Contact:

Re: pallete in memory [solved]

Post by honey data »

my marina is the gui im have install on my pc is a gui in pt name tradutor

http://www.ibiblio.org/pub/micro/pc-stu ... /seal.html
Post Reply