22 April 2013, 08:39 | #1 |
Registered User
Join Date: Aug 2008
Location: Göteborg / Sweden
Posts: 237
|
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 |
22 April 2013, 09:29 | #2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
InitRastPort() is missing.
|
22 April 2013, 10:19 | #3 |
Registered User
Join Date: Aug 2008
Location: Göteborg / Sweden
Posts: 237
|
Confirmed, thank you!
|
22 April 2013, 10:53 | #4 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
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. |
22 April 2013, 10:58 | #5 |
Registered User
Join Date: Aug 2008
Location: Göteborg / Sweden
Posts: 237
|
Yep, happily blits text now. Unfortunately AllocBitMap() is V39 and I need to support V37.
|
22 April 2013, 11:31 | #6 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
Ok, it's not 2.0+ but 3.0+, but my hint is still valid. Both SetABPenDrMd and AllocBitMap only exist in 3.0+.
|
22 April 2013, 15:00 | #7 |
Registered User
Join Date: Aug 2008
Location: Göteborg / Sweden
Posts: 237
|
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 |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
I need quick transparent blitting | meynaf | Coders. General | 15 | 13 November 2020 16:08 |
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 |
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 |
|
|