English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 22 April 2013, 08:39   #1
MagerValp
Registered User
 
Join Date: Aug 2008
Location: Göteborg / Sweden
Posts: 236
What's wrong with my blitting code?

Hi all,
instead of Text()ing straight into my window's rastport I'd like to write it to an offscreen bitmap and then blit that. For some reason all I get is garbled graphics. Could someone please tell me what I'm doing wrong here?

Test program with source:

https://www.dropbox.com/s/l3kc3992e9u6g5e/testblit.lha

Relevant snippet:
Code:
    NEW bm
    InitBitMap(bm, 4, 256, 8)
    FOR i := 0 TO 3
        bm.planes[i] := NIL
    ENDFOR
    FOR i := 0 TO 3
        bm.planes[i] := AllocRaster(256, 8)
        IF bm.planes[i] = NIL
            Raise("MEM")
        ENDIF
    ENDFOR
    
    NEW rp
    InitRastPort(rp) -> This was missing, thanks to thomas for pointing it out
    rp.bitmap := bm
    SetRast(rp, 8)
    
    SetABPenDrMd(rp, 15, 14, RP_JAM2)
    SetFont(rp, font)
    Move(rp, 0, rp.font.baseline)
    Text(rp, ' Text() into off screen bitmap ', 31)
    
    BltBitMapRastPort(bm, 0, 0,
                      w.rport, 32, 48,
                      256, 8,
                      $0c0)

Last edited by MagerValp; 22 April 2013 at 10:20. Reason: Updated with answer from thomas
MagerValp is offline  
Old 22 April 2013, 09:29   #2
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 5,843
InitRastPort() is missing.
thomas is offline  
Old 22 April 2013, 10:19   #3
MagerValp
Registered User
 
Join Date: Aug 2008
Location: Göteborg / Sweden
Posts: 236
Confirmed, thank you!
MagerValp is offline  
Old 22 April 2013, 10:53   #4
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 5,843
So now it works as intended?

One more hint: you are using SetABPenDrMd which only exists in 2.0+. Knowing this you could also use AllocBitMap which would be much easier than to allocate and initialize your own bitmap structure.
thomas is offline  
Old 22 April 2013, 10:58   #5
MagerValp
Registered User
 
Join Date: Aug 2008
Location: Göteborg / Sweden
Posts: 236
Yep, happily blits text now. Unfortunately AllocBitMap() is V39 and I need to support V37.
MagerValp is offline  
Old 22 April 2013, 11:31   #6
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 5,843
Ok, it's not 2.0+ but 3.0+, but my hint is still valid. Both SetABPenDrMd and AllocBitMap only exist in 3.0+.
thomas is offline  
Old 22 April 2013, 15:00   #7
MagerValp
Registered User
 
Join Date: Aug 2008
Location: Göteborg / Sweden
Posts: 236
Ah, you're right, this is just my test code though, the real code doesn't call SetABPenDrMd at all:

https://github.com/MagerValp/ArcadeG...GS2Menu.e#L249
MagerValp is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blitting question sandruzzo Coders. General 30 06 April 2011 11:29
Bitmaps in FASTRAM and blitting - C++ NovaCoder Coders. General 22 01 December 2010 23:40
I need quick transparent blitting meynaf Coders. General 13 24 June 2010 13:16
Blitting with size 1x255 JackAsser Coders. Tutorials 10 16 February 2010 20:49
difference in blitting uae vs. hw yoki Coders. General 5 15 July 2009 15:21

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:25.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Page generated in 0.06754 seconds with 15 queries