Aros/開發者/文件/庫/CGFX
cybergraphics.library 是針對原生 graphics.library 的 15、16、24 或 32 點陣圖形板擴充套件。 在 OS3.1 之前,系統中沒有在系統友好方式下將自定義板新增到顯示資料庫的可能性,因此它修補了某些原始圖形函式以將自定義圖形板整合到系統中。
幾乎所有標準的 8 位應用程式都可以在此 15/16/24 位螢幕上執行。 但它只能使用其他功能(如果它知道 CyberGraphics 的話)。
對於寫入畫素、讀取畫素和快速繪製,可以使用 FillPixelArray、MovePixelArray、ReadPixelArray、ScalePixelArray、SwapPixelArray、WritePixelArray 和 WriteRGBPixel 函式。
從 OS 3.x 開始,添加了兩個新的圖形呼叫來支援點陣圖建立和刪除:AllocBitmap()(圖形庫)和 FreeBitmap()(圖形庫)。 這些呼叫實現了支援自定義點陣圖格式的第一步。 之前,直接渲染到平面或對點陣圖資料的結構進行假設毫無問題。 要獲取有關點陣圖資料的更多資訊,請使用 GetBitmapAttr()(來自圖形庫)。 使用它,可以獲取有關點陣圖的寬度、高度、深度和某些標誌的資訊。
這是邁向 RTG 的第一步,例如,向 AllocBitMap() 等新增深度屬性。
只要 GetBitmapAttr(bm,BMA_FLAGS) 未返回 BMF_STANDARD,點陣圖就無法直接訪問,只能透過附加到 rastport 並進行後續渲染呼叫,或者使用標準點陣圖作為目標進行快速繪製呼叫來訪問。
不幸的是,許多程式沒有遵循這些準則,並且沒有在 OS3.0 及更高版本中檢查 BMF_STANDARD 標誌。 Cybergrphx 版本的 GetBitMapAttr (點陣圖, P96BMA_MEMORY) 必須使用 LockBitMapAddress(),其值為 LBMI_BASEADDRESS,並且不要忘記使用 LBMI_BYTESPERROW。
在 CyberGraphX 中,你還需要在 AllocBitmap()/gfx 的 flags 欄位中新增 BMF_MINPLANES。 現在還可以分配裝置相關的畫素格式點陣圖和標準 15/16/24/32 位深度影像圖。 因此,在 AllocBitmap() 的 32 位 flags 欄位引數中添加了新的位。 如果你指定了 BMB_SPECIALFMT 位(請參閱包含檔案),flags 長字的最高 8 位將包含有關所請求點陣圖的畫素格式的資訊。
分配完成後,你可以將返回的點陣圖附加到 rastport 並進行渲染呼叫。 **不允許** 透過使用 OpenScreenTagList() 將此點陣圖附加到螢幕作為自定義點陣圖!
只要點陣圖沒有 **鎖定**,你就無法直接訪問點陣圖影像資料。 影像資料的地址和內容可能會發生變化,只有在使用可用的鎖定呼叫鎖定它時才有效。 LockBitmapTags()/UnLockBitmap() 已為此目的新增。 你 **必須** 使用 LockBitmapTags() 提供包含指向長字的指標的標籤列表,如果呼叫返回非零值,則這些長字將填充有效資料。 只有在返回非零值時,你才能直接訪問點陣圖! 檢查使用 LBMI_BASEADDRESS 標籤返回的地址。 這是你進行渲染的基地址。
哪些標誌是為 AllocBitMap 建立可鎖定點陣圖所需的? 其他任何結果都會導致“無鎖定”訊息
LONG modulo;
APTR buffer;
APTR lock = LockBitMapTags(bitmap, LBMI_BASEADDRESS, &buffer, LBMI_BYTESPERROW, &modulo, TAG_DONE);
if (lock)
{
/* Manipulate bitmap here */
UnlockBitMapTags(lock);
}
#include <proto/graphics.h>
#include <cybergraphx/cybergraphics.h>
#include <proto/cybergraphics.h>
#include <stdio.h>
struct BitMap *bitmap;
APTR handle;
IPTR buffer;
int main(void)
{
bitmap = AllocBitMap(400, 300, 32,
/*BMF_MINPLANES | BMF_DISPLAYABLE | */ BMF_SPECIALFMT | SHIFT_PIXFMT(PIXFMT_ABGR32), NULL);
if (bitmap)
{
//handle = LockBitMapTags(bitmap, LBMI_BASEADDRESS, &buffer, TAG_DONE);
handle = LockBitMapTags(bitmap, TAG_DONE);
if (handle)
{
printf("buffer %x\n", (unsigned int)buffer);
UnLockBitMap(handle);
}
else
{
puts("no lock");
}
FreeBitMap(bitmap);
}
else
{
puts("no bitmap");
}
return 0;
}
是否存在返回點陣圖是否可鎖定的函式? 不存在。 cgx 自動文件說明 LockbitMap 如果無法鎖定點陣圖,則返回 0。 它沒有說明,如果點陣圖曾經成功鎖定,則可以每次都成功鎖定。 因此,告知點陣圖是否可鎖定的函式實際上並不能提供幫助。
我將讓程式碼檢查 LockBitMap() 的返回值。 如果為 0(失敗),則執行解決方法(WritePixelArray()),否則執行直接點陣圖訪問。 或者,如果出於某種原因,這並非最佳/有效方法,請使其可配置程式是否應(嘗試)使用 LockBitMap。
否則,對於 vice,這意味著它必須進行“測試”鎖定並檢視是否有效,如果有效,則程式碼可以使用鎖定程式碼,否則需要使用 WritePixelArray 程式碼。
即使這在當前驅動程式中可能有效,但我認為最好每次在每次 LockBitMap() 呼叫時都檢查返回值。
如果 aros 針對這種情況有一些備用程式碼,那會容易得多。 例如,如果點陣圖鎖定不受支援,但仍呼叫它,則 aros 會分配一個緩衝區,將點陣圖複製到其中,向呼叫者提供緩衝區的地址,呼叫者執行任何操作,當鎖定被釋放時,aros 會將點陣圖複製回(或者如果它更快,則僅複製更改),並釋放緩衝區。
如前所述,這將很慢。 但是,如果你願意,可以嘗試自行編寫自己的 MyLockBitMap() 函式,這些函式的工作方式與你所描述的相同。
這是可能的,但速度會非常慢,因為無法確定 LockBitMap() 呼叫者將執行什麼操作。 他將訪問點陣圖的哪些部分。 他是否會讀取畫素、寫入畫素或同時執行這兩項操作。 因此,後備程式碼需要分配一個畫素緩衝區並將整個點陣圖讀取到其中。
所有繪圖函式都在點陣圖上執行。 rastport 本質上只是一個包含圖形上下文(前景色、線條圖案、繪圖模式)的結構。 大多數繪圖函式都需要 rastport。(rastport 不一定會附帶自己的點陣圖!)。
你可以建立一些 rastport。 你可以建立一些點陣圖。 你可以將這兩者連線起來(將指向點陣圖的指標放到 rastport 中)。 然後,你可以在 rastport 中進行渲染,它將進入你的點陣圖。
struct RastPort rp; InitRastPort(&rp); [...] /* Use rastport */ [...] DeinitRastPort(&rp);
struct RastPort *rp;
if ((rp = CreateRastPort()))
{
[...]
/* use rastport */
FreeRastPort(rp);
}
如果使用在 15 位(或更高位)工作臺中執行的視窗應用程式。 該應用程式使用離屏點陣圖進行渲染,然後使用 ClipBlit() 將內容複製到視窗中。 假設我的離屏點陣圖是工作臺螢幕點陣圖的朋友,並且至少有 15 位深度,我們如何任意設定想要使用的顏色? 基本上,你需要 GetColorMap(),然後是一系列 SetRGB32CM()。
win->WScreen->ViewPort.Colormap
那麼,我們如何獲取指向它的指標並將其提供給 ObtainPen() 以獲得我的自定義繪製顏色,對吧?最好使用 ObtainBestPen()。
以與螢幕相同的格式分配點陣圖 (wb) 點陣圖,以獲得最佳效能
bm = AllocBitMap(width, height, depth, BMF_MINPLANES, screen->RastPort.BitMap);
將光柵埠與點陣圖連線
rp->BitMap = bm;
不過請注意,這種方式你根本不會得到任何剪裁,所以不要在點陣圖尺寸之外渲染,否則會導致崩潰(在 AROS/託管/x11 下不一定會發生,因為 x11 會剪裁所有內容)。
如果你真的需要剪裁,那麼你必須安裝一個 layerinfo 以及一些與你的點陣圖相連的層,然後使用 layer->rp 作為光柵埠。
你需要強制區分索引顏色和真彩色。要在索引模式下繪製單個畫素,可以使用 graphics.library/WritePixel()。要在真彩色模式下使用 RGB 值繪製單個畫素,可以使用 cybergraphics.library/WriteRGBPixel。
要繪製多個索引畫素,可以使用 graphics.library/WritePixelLine8() 或 WritePixelArray8() 或 WriteChunkyPixels()。在真彩色螢幕上繪製多個 *仍然是索引* 的畫素,可以使用 cybergraphics.library/WriteLUTPixelArray()。
要在真彩色螢幕上繪製 RGB 畫素,可以使用 cybergraphics.library/WritePixelArray(rectfmt = RECTFMT_RGB 或 RECTFMT_ARGB 或 RECTFMT_RGBA)。
RGB = R8 G8 B8 R8 G8 B8... ARGB = A8 R8 G8 B8 A8 R8 G8 B8... ...
在記憶體中,獨立於計算機的位元組序。
畫素緩衝區將自動轉換為目標點陣圖畫素格式,但這種轉換可能很慢,因為我們只有一個通用的慢速轉換例程。
更好的方法是使用 RECTFMT_RAW,這意味著與目標點陣圖相同的畫素格式。然後,你必須在呼叫 WritePixelArray(RECTFMT_RAW) 之前自己進行轉換。
不幸的是,沒有專門的函式可以執行類似 WritePixelArray() 的操作,但帶有掩碼。
線繪製:嗯,這是透過 Move(rp, x1, y1) 和 Draw(rp, x2, y2) 完成的。目前,這在真彩色螢幕上僅適用於使用特定 RGB 顏色的技巧。預設情況下,顏色基於筆/索引,在索引螢幕和真彩色螢幕上都是如此,在真彩色螢幕上,顏色透過 SetAPen() 設定。
不幸的是,沒有用於多邊形函式的類似東西。目前,這些函式由 graphics.library 以舊式方式渲染到 1 平面點陣圖中,然後使用 BltPattern() 放入目標 rp/點陣圖中。
順便說一下,你使用 AllocScreenBuffer 命令獲得的 BitMap 與螢幕相同,因此它適用於加速操作。你只需將螢幕緩衝區中的點陣圖連結到 RastPort,即可與需要光柵埠的圖形庫命令一起使用。同樣,這是在 Amiga 上。在 AROS 中也讓它正常工作將是一件好事。
/*
Example for bitmaps
*/
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <graphics/gfxmacros.h>
#include <stdlib.h>
#include <stdio.h>
static struct Window *window;
static struct ColorMap *cm;
static struct RastPort *win_rp;
#define BMWIDTH (50)
#define BMHEIGHT (50)
struct BitMap *bm;
struct RastPort *bm_rp;
/*
ObtainBestPen() returns -1 when it fails, therefore we
initialize the pen numbers with -1 to simplify cleanup.
*/
static LONG pen1=-1;
static LONG pen2=-1;
static void draw_bitmap(void);
static void clean_exit(CONST_STRPTR s);
static void handle_events(void);
int main(void)
{
window = OpenWindowTags(NULL,
WA_Left, 50,
WA_Top, 70,
WA_Width, 400,
WA_Height, 350,
WA_Title, "Bitmap Graphics",
WA_Activate, TRUE,
WA_SmartRefresh, TRUE,
WA_NoCareRefresh, TRUE,
WA_GimmeZeroZero, TRUE,
WA_CloseGadget, TRUE,
WA_DragBar, TRUE,
WA_DepthGadget, TRUE,
WA_IDCMP, IDCMP_CLOSEWINDOW,
TAG_END);
if (! window) clean_exit("Can't open window\n");
win_rp = window->RPort;
cm = window->WScreen->ViewPort.ColorMap;
// Let's obtain two pens
pen1 = ObtainBestPen(cm, 0xFFFF0000, 0, 0, TAG_END);
pen2 = ObtainBestPen(cm, 0, 0, 0xFFFF0000, TAG_END);
if ( !pen1 || !pen2) clean_exit("Can't allocate pen\n");
draw_bitmap();
handle_events();
clean_exit(NULL);
return 0;
}
static void draw_bitmap(void)
{
/*
Get the depth of the screen. Don't peek in the structures, always use
GetBitMapAttr().
*/
UWORD depth = GetBitMapAttr(win_rp->BitMap, BMA_DEPTH);
/*
Create new bitmap. With BMF_MINPLANES and the bitmap pointer we are saying
that we want a bitmap which is similar than the target bitmap.
*/
bm = AllocBitMap(BMWIDTH, BMHEIGHT, depth, BMF_MINPLANES, win_rp->BitMap);
if (!bm) clean_exit("Can't allocate bitmap\n");
bm_rp = CreateRastPort(); // Create rastport for our bitmap
if (!bm_rp) clean_exit("Can't allocate rastport!\n");
bm_rp->BitMap = bm; // Link bitmap to rastport
/*
Now we can draw into our bitmap. Take care that the bitmap has no
clipping rectangle. This means we must not draw over the limits.
*/
SetRast(bm_rp, 0); // fill whole bitmap with color 0
SetAPen(bm_rp, pen1);
DrawCircle(bm_rp, 24, 24, 24);
SetAPen(bm_rp, pen2);
Move(bm_rp, 0, 0);
Draw(bm_rp, 49, 49);
Move(bm_rp, 49, 0);
Draw(bm_rp, 0, 49);
Draw(bm_rp, 49, 49);
Draw(bm_rp, 49, 0);
Draw(bm_rp, 0, 0);
Draw(bm_rp, 0, 49);
int x;
for (x=20; x<400 ; x+=30)
{
// Blit the bitmap into the window
ClipBlit(bm_rp, 0, 0, win_rp, x, x/2, BMWIDTH, BMHEIGHT, 0xC0);
}
}
static void handle_events(void)
{
/*
A simple event handler. This will be explained more detailed in the Intuition examples.
*/
struct IntuiMessage *imsg;
struct MsgPort *port = window->UserPort;
BOOL terminated = FALSE;
while (!terminated)
{
Wait(1L << port->mp_SigBit);
if ((imsg = (struct IntuiMessage *)GetMsg(port)) != NULL)
{
switch (imsg->Class)
{
case IDCMP_CLOSEWINDOW:
terminated = TRUE;
break;
}
ReplyMsg((struct Message *)imsg);
}
}
}
static void clean_exit(CONST_STRPTR s)
{
if (s) PutStr(s);
// Give back allocated resourses
if (bm) FreeBitMap(bm);
if (bm_rp) FreeRastPort(bm_rp);
if (pen1 != -1) ReleasePen(cm, pen1);
if (pen2 != -1) ReleasePen(cm, pen2);
if (window) CloseWindow(window);
exit(0);
}
緩衝(雙緩衝或多緩衝)
[edit | edit source]DBufInfo dbi
[edit | edit source]struct DBufInfo STRUCTURE DBufInfo,0 APTR dbi_Link1 ULONG dbi_Count1 STRUCT dbi_SafeMessage,MN_SIZE APTR dbi_UserData1 APTR dbi_Link2 ULONG dbi_Count2 STRUCT dbi_DispMessage,MN_SIZE APTR dbi_UserData2 ULONG dbi_MatchLong APTR dbi_CopPtr1 APTR dbi_CopPtr2 APTR dbi_CopPtr3 UWORD dbi_BeamPos1 UWORD dbi_BeamPos2 LABEL dbi_SIZEOF
只有這些才能被使用:dbi_SafeMessage、dbi_DispMessage、dbi_UserData1 和 dbi_UserData2
The following fragment shows proper double buffering synchronization:
int SafeToChange=TRUE, SafeToWrite=TRUE, CurBuffer=1;
struct MsgPort *ports[2]; /* reply ports for DispMessage and SafeMessage
*/
struct BitMap *BmPtrs[2];
struct DBufInfo *myDBI;
... allocate bitmap pointers, DBufInfo, set up viewports, etc.
myDBI->dbi_SafeMessage.mn_ReplyPort=ports[0];
myDBI->dbi_DispMessage.mn_ReplyPort=ports[1];
while (! done)
{
if (! SafeToWrite)
while(! GetMsg(ports[0])) Wait(1l<<(ports[0]->mp_SigBit));
SafeToWrite=TRUE;
... render to bitmap # CurBuffer.
if (! SafeToChange)
while(! GetMsg(ports[1])) Wait(1l<<(ports[1]->mp_SigBit));
SafeToChange=TRUE;
WaitBlit(); /* be sure rendering has finished */
ChangeVPBitMap(vp,BmPtrs[CurBuffer],myDBI);
SafeToChange=FALSE;
SafeToWrite=FALSE;
CurBuffer ^=1; /* toggle current buffer */
}
if (! SafeToChange) /* cleanup pending messages */
while(! GetMsg(ports[1])) Wait(1l<<(ports[1]->mp_SigBit));
if (! SafeToWrite) /* cleanup */
while(! GetMsg(ports[0])) Wait(1l<<(ports[0]->mp_SigBit));
ScrollVPort
[edit | edit source]這是我針對 cybergraphics 螢幕的雙緩衝演算法:我分配了一個高度為兩倍的螢幕(不可拖動),在我的不可見區域(通常是下半部分)進行所有螢幕外渲染,完成後,我執行一次巨大的 blit(ClipBlit)將下半部分的所有內容複製到螢幕的可見區域(上半部分)。即使在大螢幕和高深度情況下,這也能非常快地工作。
/* multibuffering use ScrollVPort() on double height screen and sync with WaitBOV() but AVOID WaitTOF() */
/* struct Screen *screen = OpenScreenTags() with SA_HEIGHT equal to 960
Then screen->Viewport->RasInfo->RyOffset = 480; ScrollVport(screen->ViewPort); WaitBOVP(screen->ViewPort);
check overscan set
RTG modes do not use sprites (except mouse) use BltBitMap functions instead */
/* Create double height display */
fb->bm = bm_create_disp(width, height*2, depth);
/* Screen Taglist here */
fb->screen = OpenScreen(&newScreen);
/* To get bitmap pointer */
bloqueo=(APTR)LockBitMapTags(*rastportptr->BitMap,LBMI_BASEADDRESS, &direccionbase,TAG_DONE);
/* made the double buffer changing the RasInfo->RyOffset value, and executing ScrollVPort and WaitBOVP */
fb->screen->ViewPort.RasInfo->RyOffset = fb->frame*fb->height;
fb->frame ^= 1;
fb->frameOffset = fb->frame*fb->height;
ScrollVPort(&fb->screen->ViewPort);
WaitBOVP(&fb->screen->ViewPort);
ChangeScreenBuffer(AROS 壞了?)
[edit | edit source]資源 這裡
// Flip.
while (ChangeScreenBuffer(video_screen, screenBuffer[drawBuffer]) == 0) {
/* do nothing! */ ;
}
其想法是,如果 ChangeScreenBuffer() 無法進行翻轉,則會返回 0,並且可能在內部執行訊號檢查操作。對於雙緩衝,你可以使用標準的雙緩衝函式,例如圍繞 AllocScreenBuffer 的函式。
Struct ScreenBuffer
sb[0] = AllocScreenBuffer(screen, NULL, SB_SCREEN_BITMAP);
sb[1] = AllocScreenBuffer(screen, NULL, SB_COPY_BITMAP);
ports[0] = CreateMsgPort();
ports[1] = CreateMsgPort();
UBYTE toggle=0; //
sb[toggle]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort = ports[0];
sb[toggle]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort = ports[1];
Wait(1l << (ports[1]->mp_SigBit));
ChangeScreenBuffer(screen, sb[toggle]);
toggle ^= 1; //
Wait(1l << (ports[0]->mp_SigBit));
還有一個 Commodore 示例 doublebuffer.c,以及 CyberAnim13.lha,可以參考。
相反,你應該使用 CGX API 的 WritePixelArray() 或 WriteLUTPixelArray(),或 graphisc[檢查拼寫].library 的 WriteChunkyPixels()。請注意,WriteChunkyPixels() 僅在 Kickstart 3.1 中可用,因此你必須為 3.0 使用者添加回退例程。
請注意,你不能直接寫入沒有設定 BMF_STANDARD 標記的點陣圖!
檢視 CGX 開發工具包。它解釋了 RTG 系統的限制,以及你需要考慮的因素(尤其是點陣圖中的 BMF_STANDARD 標記)。
有沒有辦法避免過度閃爍並讓顯示行為更像正常情況?
目前,AROS 只有一個通用的非最佳化 RGB 格式轉換例程,當然很慢。對於常見情況(如 ARGB32 到 RGB15),沒有特殊的轉換例程。你可以自己進行轉換,然後使用 RECTFMT_RAW。
灰色條/閃爍。你是否直接將 WritePixelArray() 寫入視窗 RastPort?原始程式碼(如果使用 LockBitMap())不太可能這樣做,因此你也不應該這樣做,除非這是一個一次性寫入的完整“幀”。或者將畫素收集到一個完整的幀畫素緩衝區中,並在一個完整的幀“準備就緒”後對視窗執行 WritePixelArray()。或者將 WritePixelArray() 寫入螢幕外點陣圖,並在一個完整的幀“準備就緒”後將該點陣圖 BltBitMapRastPort() 到視窗。
或者可能是雙緩衝函式(AllocScreenBuffer()、ChangeScreenBuffer() 等)在 AROS 中尚未正常工作。
AROS 的 CGFX 實現不能只使用針對任何架構“正確”的 RECTFMT 的內部查詢嗎?
程式設計師編寫 RACTFMT_BGR32 -> CGFX 在執行正常操作之前對其進行解釋?或者這會導致速度過慢?無需在 CGFX 實現中更改任何內容。只需在 libraries/cybergraphics.h 中重新定義一些 pixfmt/rectfmt id 即可。
WritePixelArrayAlpha 在 AROS 上到底做了什麼?來自 workbench/hidds/graphics BM_Class.c 中的 BM__Hidd_BitMap__PutAlphaImage()。當 gfx 驅動程式沒有覆蓋重實現它時,這是回退程式碼。
螢幕模式
[edit | edit source]Cybergrafix 支援一些非常精細的函式來選擇螢幕模式,例如 BestCModeIDTagList,它可以獲取指定螢幕屬性標記列表的最佳螢幕模式。
畫素格式
[edit | edit source]以下畫素格式可用
PIXFMT_LUT8,PIXFMT_RGB15,PIXFMT_BGR15,PIXFMT_RGB15PC,PIXFMT_BGR15PC, PIXFMT_RGB16,PIXFMT_BGR16,PIXFMT_RGB16PC,PIXFMT_BGR16PC,PIXFMT_RGB24, PIXFMT_BGR24,PIXFMT_ARGB32,PIXFMT_BGRA32,PIXFMT_RGBA32
許多畫素格式是裝置特定的,不應使用,推薦的格式是 PIXFMT_LUT8、PIXFMT_RGB16、PIXFMT_RGB24 和 PIXFMT_ARGB32。
獲取 LBMI_PIXFMT ULONG 欄位的值,以獲取有關你必須用於影像渲染的顏色模型的資訊。所有模型都必須支援!其他欄位提供有關點陣圖資料佈局的資訊。直接渲染到點陣圖應該沒有問題。請記住,所有這些值僅在下次呼叫 UnLockBitmap() 之前有效。之後,你必須再次鎖定點陣圖。不要將此鎖定保持超過一幀時間!你可以使用標準的 graphics.library 點陣圖 blitting 呼叫將點陣圖內容複製到另一個位圖。目前不支援將真彩色點陣圖複製到索引顏色塊狀點陣圖中。
鎖定點陣圖以直接寫入 gfx 卡記憶體將需要你使用 cgx 函式。否則,你必須使用類似 WritePixelArray 的函式。開啟 cgx 庫很好,因為它適用於帶有 rtg 的經典 miggies(cgx & p96 都可以使用)。
如何修復直接點陣圖訪問。首先,我想刪除擴充套件畫素格式定義
#define PIXFMT_ABGR32 100UL #define PIXFMT_0RGB32 101UL #define PIXFMT_BGR032 102UL #define PIXFMT_RGB032 103UL #define PIXFMT_0BGR32 104UL
它們可能會讓程式感到困惑,因為它們不知道這些定義。此外,0RGB32(例如)實際上與 ARGB32 相同,這是標準定義。唯一的問題是 ABGR32 格式。預計它是 RGBA32 的其他位元組序版本。我想檢查一下有些 GFX 卡是否真的使用 ABGR32。
在這些卡上,monitorclass 測試會報告沒有已知的畫素格式被支援。作為測試,monitorclass 不支援擴充套件畫素格式。如果沒有,我會將 ABGR32 格式保留在規範中,但將其編號為 14,緊挨著 RGBA32。這對 monitorclass 來說會舒服得多(它在一個地方使用畫素格式索引的陣列)。
目前只有一個使用 RGBA32 格式的驅動程式。它是 Windows 宿主驅動程式。Windows GDI 在內部使用此畫素格式。如果我們假設 Windows 執行在大端 CPU 上,它將變成 ABGR32。另一方面,世界上將不再有其他大端 CPU。此外,這可以透過軟體修復。
從 CGX 中刪除錯誤的畫素格式程式碼幾乎可以完成這項工作。另一個將是在一些軟體中刪除位元組序轉換。畫素格式描述了畫素在 RAM 中的佈局方式,因此不需要交換位元組。
- 直接渲染到點陣圖可以工作,但前提是圖形驅動程式支援它。Nvidia 驅動程式支援,大多數其他驅動程式不支援。
- AROS Cybergraphics 中的畫素和矩形格式始終指記憶體中的佈局。因此 RECTFMT_ARGB 表示 0xAA 0xRR 0xGG 0xBB。無論是在大端還是小端機器上執行,都是如此。在小端(x86)機器上執行時,瞭解這一點很重要,因為如果你有一個 ULONG 畫素陣列/緩衝區,你使用畫素(ULONG)訪問在其中寫入 ARGB 畫素,那麼在記憶體中它將看起來像 0xBB 0xGG 0xRR 0xAA,你需要使用 RECTFMT_BGRA。
如果你有一個使用 PIXFMT_RGB16PC 的螢幕,但 WORD 畫素緩衝區,那麼在 AROS 小端上你需要使用 RECTFMT_RGB16,而在 AROS 大端上則需要使用 RECTFMT_RGB16PC。
由於 rectfmt/pixfmt 的實際含義有時並不直觀(#if AROS_BIG_ENDIAN do_this #else do_that),所以計劃修改庫/cybergraphics.h,使其將 rectfmt 畫素格式的含義從“基於”記憶體佈局改為基於畫素訪問。
順便說一下,還有 RECTFMT_RAW,它表示與點陣圖格式相同的格式。
AROS 的 CGFX 實現不能只使用針對任何架構“正確”的 RECTFMT 的內部查詢嗎?
程式設計師編寫 RACTFMT_BGR32 -> CGFX 在執行正常操作之前對其進行解釋?或者這會太慢了?
使用 WritePixelArray 到一個離屏點陣圖(沒有分配為可見的)更快嗎?
硬體加速:如果需要,圖形驅動程式可以覆蓋/重新實現 PutAlphaImage() 方法。但我不知道這是否有意義,或者是否完全可能,因為使用 WritePixelArrayAlpha() 你有一個 ARGB 畫素緩衝區,它很可能在 RAM 中。如果圖形卡可以加速此操作,它們可能需要將畫素放在 VRAM 中。我不知道。
位元組序
[edit | edit source]這是一個位元組序問題。在 AROS 大端上,它與 AOS/MOS 完全相同。因為在大端機器上,畫素訪問/元件訪問/記憶體佈局沒有區別。如果你寫入一個 0xAARRGGBB ULONG 到記憶體,它在記憶體中也將是 0xAA 0xRR 0xGG 0xBB。同樣的事情。沒問題。
在小端機器上,RECTFMT/PIXFMT 應該反映基於畫素訪問的含義(單位 == 畫素)還是基於記憶體佈局的含義(單位 == 位元組或元件),這是一個設計決定。因為 RECTFMT_ARGB 並不意味著必須始終使用 ULONG 畫素緩衝區,並且只使用 ULONG 畫素訪問。也可以使用位元組/元件訪問。或者將這些畫素緩衝區讀寫到磁碟。
但是如果你不喜歡這樣,可以透過在你的程式碼中新增類似以下內容來輕鬆修復
#if !AROS_BIG_ENDIAN #define PIXFMT_LUT8 0UL #define PIXFMT_RGB15 3UL /* RGB15PC */ #define PIXFMT_BGR15 4UL /* BGR15PC */ #define PIXFMT_RGB15PC 1UL /* RGB15 */ #define PIXFMT_BGR15PC 2UL /* BGR15 */ #define PIXFMT_RGB16 7UL /* RGB16PC */ #define PIXFMT_BGR16 8UL /* BGR16PC */ #define PIXFMT_RGB16PC 5UL /* RGB16 */ #define PIXFMT_BGR16PC 6UL /* BGR16 */ #define PIXFMT_RGB24 10UL /* BGR24 */ #define PIXFMT_BGR24 9UL /* RGB24 */ #define PIXFMT_ARGB32 12UL /* BGRA32 */ #define PIXFMT_BGRA32 11UL /* ARGB32 */ #define PIXFMT_RGBA32 113UL /* ABGR32 */ #endif
至少目前是這樣。如前所述,計劃將這種選項新增到庫/cybergraphics.h 中。然後,你可以在包含庫 cybergraphics.h 之前進行 #define CGX_PIXEL_BASED_FMT_IDS(或其他更合適的名稱),這樣就完成了。
使用原始 cgfx 函式(以及 GetCyberMapAttr 等函式的屬性)的應用程式永遠不會看到這些值。
是的,但是隻有 GetCyberMapAttr() 處理這個。其他地方將它們傳遞給應用程式。
還引入了 CYBRMATTR_PIXFMT_ALPHA,它表示“不要對映,我知道 0RGB32 等 pixfmt”。如果你想保留它。
例如,driver_GetCyberMapAttr() 似乎將 0RGB32、BGR032 等正確對映到 ARGB32、BGRA32 等,以便(舊版)應用程式只獲得它們期望的值。在其他地方(呼叫 hidd2cyber_pixfmt()),這個功能缺失/被遺忘了。
你可以 (*) 在 hidd2cyber_pixfmt() 函式中新增一個 BOOL 引數,它指示是否將 0RGB32 等對映到 ARGB32 等。然後,在大多數呼叫 hidd2cyber_pixfmt() 的函式中傳遞 FALSE。
CGFX 為 Cairo 修復
[edit | edit source]Cybergrafix 支援一個函式來獲取有關(修改後的)Bitmap 結構的一些資訊,但是(遺憾的是)你無法獲得影片記憶體的地址。因此你無法直接寫入影片記憶體。
出於與 Cybergraphics API 相關的歷史原因,graphics.hidd 會在讀取 24->32 位或寫入 32->24 位時將 alpha 值設定為 0。pixman 將(正確地)解釋畫素為透明。因此,在我們將畫素資料提供給 cairo 之前,我們必須透過強制 alpha 值為 0xff 來修復它。
我們必須處理非原生位元組序 RGB 格式,這使得情況更加複雜。兩個可用格式(實際上)是 xRGB 和 xBGR。對於 xBGR,我們在新增 alpha 之前進行位元組序交換,然後向下移位;也就是說 xBGR->RBGx->0RGB->ARGB。
有一天,graphics.library 會給我們一種方法,讓我們可以從 graphics.hidd 格式轉換例程中請求這一點,這樣就不需要這樣做。
我們的 CyberGraphX API 有 BltTemplateAlpha() 和 WritePixelArrayAlpha(),它們可以工作。其他函式不處理 alpha 通道,因為它們不打算這樣做。對於 CGX ARGB 畫素格式,實際上表示 0RGB。
我認為這是專門針對硬體 alpha 處理的。
修復 graphics.library 和 gfx.hidd 中的硬體和軟體 alpha 通道支援。
- 必須啟用至少一個支援硬體 alpha 的驅動程式才能演示其功能。
- 還必須提供一個演示其使用方法的測試應用程式。
我認為目前所有驅動程式都透過軟體方法實現 PutAlphaImage。如果我沒記錯的話,我從 nvidia 中借用了 nouveau 中的實現,該實現是
對於 alpha 啟用的影像的每個畫素,檢查 alpha 是否不同於 0 或 0xff,如果是,則從 VRAM 中讀取畫素,使用新的 alpha 顏色應用它,並將其寫回。從 VRAM 中讀取速度非常慢,因此,當你有幾個視窗開啟並四處移動時,使用 alpha 影像的裝飾看起來很慢。
示例
[edit | edit source]#include <cybergraphx/cybergraphics.h>
#include <proto/intuition.h>
#include <proto/cybergraphics.h>
#include <stdio.h>
#include <string.h>
#define NUM_PIXFMT 14
static char *pixfmt_str[14]=
{
"LUT8",
"RGB15",
"BGR15",
"RGB15PC",
"BGR15PC",
"RGB16",
"BGR16",
"RGB16PC",
"BGR16PC",
"RGB24",
"BGR24",
"ARGB32",
"BGRA32",
"RGBA32"
};
int main(void)
{
struct Screen *scr = IntuitionBase->ActiveScreen;
if (scr)
{
struct BitMap *bm = scr->RastPort.BitMap;
LONG pixfmt;
pixfmt = GetCyberMapAttr(bm, CYBRMATTR_PIXFMT);
printf("Pixel Format: #%ld (%s)\n",
pixfmt,
((pixfmt >= 0) && (pixfmt < NUM_PIXFMT)) ? pixfmt_str[pixfmt] : "<unknown>");
}
return 0;
}
#include <dos/dos.h>
#include <intuition/intuition.h>
#include <graphics/gfx.h>
#include <cybergraphx/cybergraphics.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <proto/cybergraphics.h>
#include <proto/intuition.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define SCREENWIDTH 300
#define SCREENHEIGHT 200
#define SCREENCY (SCREENHEIGHT / 2)
/***********************************************************************************/
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct Library *CyberGfxBase;
struct Screen *scr;
struct Window *win;
struct RastPort *rp;
ULONG cgfx_coltab[256];
UBYTE Keys[128];
/***********************************************************************************/
static void cleanup(char *msg)
{
if (msg)
{
printf("WritePixelArray: %s\n",msg);
}
if (win) CloseWindow(win);
if (scr) UnlockPubScreen(0, scr);
if (CyberGfxBase) CloseLibrary(CyberGfxBase);
if (GfxBase) CloseLibrary((struct Library *)GfxBase);
if (IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
exit(0);
}
/***********************************************************************************/
static void openlibs(void)
{
if (!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 39)))
{
cleanup("Can't open intuition.library V39!");
}
if (!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 39)))
{
cleanup("Can't open graphics.library V39!");
}
if (!(CyberGfxBase = OpenLibrary("cybergraphics.library",0)))
{
cleanup("Can't open cybergraphics.library!");
}
}
/***********************************************************************************/
static void getvisual(void)
{
if (!(scr = LockPubScreen(NULL)))
{
cleanup("Can't lock pub screen!");
}
if (GetBitMapAttr(scr->RastPort.BitMap, BMA_DEPTH) <= 8)
{
cleanup("Need hi or true color screen!");
}
}
/***********************************************************************************/
static void makewin(void)
{
win = OpenWindowTags(NULL, WA_CustomScreen , (IPTR)scr,
WA_InnerWidth , SCREENWIDTH,
WA_InnerHeight , SCREENHEIGHT,
WA_Title , (IPTR)"WritePixelArray: Move mouse!",
WA_DragBar , TRUE,
WA_DepthGadget , TRUE,
WA_CloseGadget , TRUE,
WA_Activate , TRUE,
WA_IDCMP , IDCMP_CLOSEWINDOW |
IDCMP_RAWKEY,
TAG_DONE);
if (!win) cleanup("Can't open window");
rp = win->RPort;
}
/***********************************************************************************/
#define KC_LEFT 0x4F
#define KC_RIGHT 0x4E
#define KC_UP 0x4C
#define KC_DOWN 0x4D
#define KC_ESC 0x45
/***********************************************************************************/
static void getevents(void)
{
struct IntuiMessage *msg;
while ((msg = (struct IntuiMessage *)GetMsg(win->UserPort)))
{
switch(msg->Class)
{
case IDCMP_CLOSEWINDOW:
Keys[KC_ESC] = 1;
break;
case IDCMP_RAWKEY:
{
WORD code = msg->Code & ~IECODE_UP_PREFIX;
Keys[code] = (code == msg->Code) ? 1 : 0;
}
break;
}
ReplyMsg((struct Message *)msg);
}
}
/***********************************************************************************/
static void action(void)
{
static LONG tab[SCREENWIDTH * SCREENHEIGHT];
LONG x, y;
LONG ar1, ar2, ar3, ar4;
LONG ag1, ag2, ag3, ag4;
LONG ab1, ab2, ab3, ab4;
LONG r1, r2, r3, r4;
LONG g1, g2, g3, g4;
LONG b1, b2, b3, b4;
LONG tr1, tg1, tb1;
LONG tr2, tg2, tb2;
LONG tr3, tg3, tb3;
LONG tr4, tg4, tb4;
LONG ttr1, ttg1, ttb1;
LONG ttr2, ttg2, ttb2;
LONG tttr, tttg, tttb;
LONG col;
ar1 = 0xFF; ag1 = 0xFF; ab1 = 0xFF;
ar2 = 0xFF; ag2 = 0x00; ab2 = 0x00;
ar3 = 0x00; ag3 = 0xFF; ab3 = 0x00;
ar4 = 0x00; ag4 = 0x00; ab4 = 0xFF;
r1 = 0xFF; g1 = 0xFF; b1 = 0xFF;
r2 = 0xFF; g2 = 0x00; b2 = 0x00;
r3 = 0x00; g3 = 0xFF; b3 = 0x00;
r4 = 0x00; g4 = 0x00; b4 = 0xFF;
while(!Keys[KC_ESC])
{
x = scr->MouseX;
if (x < 0) x = 0; else if (x >= scr->Width) x = scr->Width - 1;
r1 = ar1 + (ar2 - ar1) * x / (scr->Width - 1);
g1 = ag1 + (ag2 - ag1) * x / (scr->Width - 1);
b1 = ab1 + (ab2 - ab1) * x / (scr->Width - 1);
r2 = ar2 + (ar3 - ar2) * x / (scr->Width - 1);
g2 = ag2 + (ag3 - ag2) * x / (scr->Width - 1);
b2 = ab2 + (ab3 - ab2) * x / (scr->Width - 1);
r3 = ar3 + (ar4 - ar3) * x / (scr->Width - 1);
g3 = ag3 + (ag4 - ag3) * x / (scr->Width - 1);
b3 = ab3 + (ab4 - ab3) * x / (scr->Width - 1);
r4 = ar4 + (ar1 - ar4) * x / (scr->Width - 1);
g4 = ag4 + (ag1 - ag4) * x / (scr->Width - 1);
b4 = ab4 + (ab1 - ab4) * x / (scr->Width - 1);
for(y = 0; y < SCREENHEIGHT; y ++)
{
for(x = 0; x < SCREENWIDTH; x++)
{
tr1 = r1 + (r2 - r1) * x / (SCREENWIDTH - 1);
tg1 = g1 + (g2 - g1) * x / (SCREENWIDTH - 1);
tb1 = b1 + (b2 - b1) * x / (SCREENWIDTH - 1);
tr2 = r3 + (r4 - r3) * x / (SCREENWIDTH - 1);
tg2 = g3 + (g4 - g3) * x / (SCREENWIDTH - 1);
tb2 = b3 + (b4 - b3) * x / (SCREENWIDTH - 1);
tr3 = r1 + (r3 - r1) * y / (SCREENHEIGHT - 1);
tg3 = g1 + (g3 - g1) * y / (SCREENHEIGHT - 1);
tb3 = b1 + (b3 - b1) * y / (SCREENHEIGHT - 1);
tr4 = r2 + (r4 - r2) * y / (SCREENHEIGHT - 1);
tg4 = g2 + (g4 - g2) * y / (SCREENHEIGHT - 1);
tb4 = b2 + (b4 - b2) * y / (SCREENHEIGHT - 1);
ttr1 = tr1 + (tr2 - tr1) * y / (SCREENHEIGHT - 1);
ttg1 = tg1 + (tg2 - tg1) * y / (SCREENHEIGHT - 1);
ttb1 = tg1 + (tg2 - tg1) * y / (SCREENHEIGHT - 1);
ttr2 = tr3 + (tr4 - tr3) * x / (SCREENWIDTH - 1);
ttg2 = tg3 + (tg4 - tg3) * x / (SCREENWIDTH - 1);
ttb2 = tb3 + (tb4 - tb3) * x / (SCREENWIDTH - 1);
tttr = (ttr1 + ttr2) / 2;
tttg = (ttg1 + ttg2) / 2;
tttb = (ttb1 + ttb2) / 2;
#if AROS_BIG_ENDIAN
col = (tttr << 16) + (tttg << 8) + tttb;
#else
col = (tttb << 24) + (tttg << 16) + (tttr << 8);
#endif
//kprintf("col[%d,%d] = %08x\n", x,y,col);
tab[y * SCREENWIDTH + x] = col;
} /* for(y = 0; y < SCREENHEIGHT; y ++) */
} /* for(y = 0; y < SCREENHEIGHT; y ++) */
WritePixelArray(tab, 0, 0, SCREENWIDTH * sizeof(LONG),
win->RPort, win->BorderLeft, win->BorderTop, SCREENWIDTH, SCREENHEIGHT,
RECTFMT_ARGB);
getevents();
} /* while(!Keys[KC_ESC]) */
}
/***********************************************************************************/
int main(void)
{
openlibs();
getvisual();
makewin();
action();
cleanup(0);
return 0; /* keep compiler happy */
}
/***********************************************************************************/
另一方面,要繪製螢幕,你也可以使用一個通用的函式,例如:WritePixelArray8(rastportptr, 0, (bufferactual-1)*(pantalla->Height/numerodebuffers ),319,199,(UBYTE *)chunkybuffer, NULL);
WritePixelArray()?在 cybergfx 函式中查詢,它們非常容易使用,並且會為你執行大量的畫素轉換。
http://thomas-rapp.homepage.t-online.de/examples/dtwin.c
struct BitMap *copy_bitmap (struct BitMap *oldbm);
BOOL load_pic (char *filename,struct BitMap **bitmap_ptr,ULONG **palette_ptr)
{
Object *o;
long ncols = 0;
struct BitMap *bitmap;
ULONG *palette;
o = NewDTObject (filename,
DTA_GroupID,GID_PICTURE,
PDTA_Remap,FALSE,
TAG_END);
if (!o) return (FALSE);
DoDTMethod (o,NULL,NULL,DTM_PROCLAYOUT,NULL,TRUE);
GetDTAttrs (o,
PDTA_NumColors, (long unsigned int)&ncols,
PDTA_CRegs,(long unsigned int) &palette,
PDTA_DestBitMap,(long unsigned int) &bitmap,
TAG_END);
if (ncols)
{
long size = ncols * 3 * sizeof(ULONG);
*palette_ptr = (ULONG*)AllocVec (size,0);
*palette_ptr = AllocVec (size,0);
if (*palette_ptr) memcpy (*palette_ptr,palette,size);
}
*bitmap_ptr = copy_bitmap (bitmap);
DisposeDTObject (o);
return (TRUE);
}
標籤... PDTA_Remap,TRUE,PDTA_Screen,scr,PDTA_DestMode,PMODE_V43... 應該啟用調色盤重新對映。
/*
gcc -noixemul -Wall -O2 truecolortest.c -o truecolortest
quit
*/
/*
* Quick'n'dirty example on how to use MorphOS truecolor rendering
*
* Written by Harry "Piru" Sintonen <sintonen@iki.fi>.
* Public Domain.
*
*/
#include <graphics/rastport.h>
#include <graphics/rpattr.h>
#include <graphics/modeid.h>
#include <intuition/screens.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <proto/dos.h>
#define MKRGB(r,g,b) (((r) << 16) | ((g) << 8) | (b))
#define WIDTH 640
#define HEIGHT 480
#define DEPTH 24
int main(void)
{
struct Screen *scr;
ULONG modeid;
int ret = RETURN_ERROR;
modeid = BestModeID(BIDTAG_NominalWidth, WIDTH,
BIDTAG_NominalHeight, HEIGHT,
BIDTAG_Depth, DEPTH,
TAG_DONE);
if (modeid == INVALID_ID)
{
Printf("could not find modeid for %lux%lux%lu mode\n",
WIDTH, HEIGHT, DEPTH);
return RETURN_WARN;
}
scr = OpenScreenTags(NULL,
SA_DisplayID, modeid,
SA_Width, WIDTH,
SA_Height, HEIGHT,
SA_Depth, DEPTH,
SA_Quiet, TRUE,
TAG_DONE);
if (scr)
{
struct BitMap *cookiebm;
cookiebm = AllocBitMap(WIDTH, HEIGHT, 1, 0, NULL);
if (cookiebm)
{
struct RastPort tmprp, *cookierp = &tmprp;
struct RastPort *rp = &scr->RastPort;
STRPTR txt;
WORD len;
LONG xmid = WIDTH / 2;
LONG ymid = HEIGHT / 2;
/* Init cookie rastport */
InitRastPort(cookierp);
cookierp->BitMap = cookiebm;
SetABPenDrMd(cookierp, 1, 0, JAM1);
/* Set screen background */
SetRPAttrs(rp, RPTAG_PenMode, FALSE,
RPTAG_FgColor, MKRGB(0xaa, 0xbb, 0xcc),
TAG_DONE);
RectFill(rp, 0, 0, WIDTH - 1, HEIGHT - 1);
/* Draw filled ellipse to cookiebm */
SetRast(cookierp, 0);
DrawEllipse(cookierp, xmid, ymid, 200, 200);
Flood(cookierp, 0, xmid, ymid);
/* Blast the cookie cut image to display */
SetRPAttrs(rp, RPTAG_DrMd, JAM1,
RPTAG_PenMode, FALSE,
RPTAG_FgColor, MKRGB(222, 100, 70),
TAG_DONE);
BltTemplate(cookiebm->Planes[0], 0,
GetBitMapAttr(cookiebm, BMA_WIDTH) / 8,
rp, 0, 0, WIDTH, HEIGHT);
/* Draw filled box */
SetRPAttrs(rp, RPTAG_PenMode, FALSE,
RPTAG_FgColor, MKRGB(40, 70, 90),
TAG_DONE);
RectFill(rp, xmid - 100, ymid - 100, xmid + 100, ymid + 100);
/* Put some text on screen, too */
SetRPAttrs(rp, RPTAG_DrMd, JAM1,
RPTAG_PenMode, FALSE,
RPTAG_FgColor, MKRGB(255, 244, 244),
TAG_DONE);
txt = "MorphOS rules!";
len = strlen(txt);
Move(rp, xmid - TextLength(rp, txt, len) / 2, ymid);
Text(rp, txt, len);
/* Wait a bit */
Delay(5 * 50);
ret = RETURN_OK;
FreeBitMap(cookiebm);
}
else Printf("no memory for %lux%lux1 cookie bitmap\n",
WIDTH, HEIGHT);
CloseScreen(scr);
}
else Printf("could not open %lux%lux%lu screen\n",WIDTH, HEIGHT, DEPTH);
return ret;
}
參考
[edit | edit source]影像類
[edit | edit source]你可以建立一個新的 boopsi 類,它是 Intuition 的 IMAGECLASS 的子類(就像這個點陣圖類),在 IM_DRAW 方法中,你可以以任何你想要的方式進行繪製。如果你有一些來自資料型別物件的點陣圖,請使用 BltBitMapRastPort(),如果你有一些塊狀畫素陣列,請使用 WritePixelArray()。
請參閱 compiler/coolimages/imageclass.c
從派生自 IMAGECLASS 的類建立的物件可以傳遞給 DrawImage()。從將 struct BitMap 轉換為 struct Image
如果使用圖形硬體的原生格式點陣圖,但它如何確保它們具有 Alpha?由於在大多數驅動程式中不可能鎖定對點陣圖的訪問,它如何獲得對畫素資料的原始陣列的訪問許可權,以便將其傳遞給 AROS 中的 Alpha 函式?使用該函式的 pixfmt 可以很容易地從點陣圖中獲取,但直到可以獲取使用的資料,它才是無意義的。
所有正常的 blit 操作都應該尊重 alpha - 應用程式應該透過分配沒有 alpha 的點陣圖等來確定它們是否會使用它(因為它們應該知道它們是否支援/需要它)。
所有部件都將使用 PutImageAlpha(慢速)繪製,而如果使用 BltNewImageSubImageRastPort 作為之前,則會嘗試檢查點陣圖的子影像是否沒有 alpha 通道畫素,如果是,則執行常規點陣圖複製(CopyBox)(更快)。影像轉換方法會檢查子影像是否沒有 alpha 畫素,如果是,則將該子影像標記為“可以從點陣圖複製”,而不是使用 WritePixelArrayAlpha。作為解決方案,以下是
- 在 CreateNewImageContainerMatchingScreen 函式中,將“每個子影像的透明度”測試移動到主程式碼路徑,使其不在真彩色中。
- 不要假設在 LUT 情況下所有子影像都可以從點陣圖中讀取,而是重複使用“每個子影像的透明度”檢查的結果。
這樣你就可以覆蓋所有使用 BltNewImageSubImageRastPort 的情況,因為它將檢測到(->subimageinbm[i])某些影像無法從 *bitmap 複製,必須使用 WritePixelArrayAlpha 繪製,無論螢幕是 LUT 還是真彩色。這也意味著 BltNewImageSubImageRastPortSimple 可以再次基於 BltNewImageSubImageRastPort。
如果你想保留背景圖案,你應該將 WritePixelArrayAlpha 放在 ClearScreen 的位置。
if (gfxdata)
{
WritePixelArrayAlpha (...);
}
else
{
SetRPAttrs(RP, RPTAG_BgColor, 0xFFFFFF, TAG_DONE);
Move (rp,0,0);
ClearScreen (rp);
}
另外,請注意 ClearScreen() 並沒有做你認為它做的事情 - 它 *不會* 清理整個視窗,它會從當前位置開始清理,因為你沒有在寫入文字後執行 Move(),所以它將位於 *文字之後* 的位置。ClearScreen 只會從當前游標位置清理到右下角。為了清除整個繪圖區域,請先執行 Move(0,0)。
AllocCModeListTagList -- get an exec list with requested modes.
AllocCModeListTags -- Varargs stub for AllocCModeListTagList
result = AllocCModeListTagList( TagItems )
D0 A1
APTR AllocCModeListTagList( struct TagItem * );
result = AllocCModeListTags( Tag1,... )
APTR AllocCModeListTags( Tag Tag1,... );
Allocates a list structure which contains all requested modes (All nodes are of type CyberModeNode). See defines for more information about the structure of this nodes.
Tags available are:
CYBRMREQ_MinWidth (ULONG) - The minimum display width to let the user choose. Default is 320.
CYBRMREQ_MaxWidth (ULONG) - The maximum display width to let the user choose. Default is 1600.
CYBRMREQ_MinHeight (ULONG) - The minimum display height to let the user choose. Default is 240.
CYBRMREQ_MaxHeight (ULONG) - The maximum display height to let the user choose. Default is 1200.
CYBRMREQ_MinDepth (UWORD) - The minimum display depth to let the user choose. Default is 8.
CYBRMREQ_MaxDepth (UWORD) - The maximum display depth to let the user choose. Default is 32.
CYBRMREQ_CModelArray (UWORD *) - Array of color models which should be available for screenmode selection. Currently supported colormodels are:
PIXFMT_LUT8
PIXFMT_RGB15
PIXFMT_BGR15
PIXFMT_RGB15PC
PIXFMT_BGR15PC
PIXFMT_RGB16
PIXFMT_BGR16
PIXFMT_RGB16PC
PIXFMT_BGR16PC
PIXFMT_RGB24
PIXFMT_BGR24
PIXFMT_ARGB32
PIXFMT_BGRA32
PIXFMT_RGBA32
default is all colormodels available, nothing filtered
The result - 0 if no modes are available, a pointer to a exec list if there
are modes which fit your needs.
where A is AlphaChannel, R is Red, B is Blue, G is Green and the number is bits per...
BestCModeListTagList ()
BestCModeIDTagList( TagItems )
void FreeCModeList ( struct List * );
GetBitmapAttr()
CModeRequestTagList ()
ULONG GetCyberMapAttr(struct BitMap *bitMap, ULONG attribute)
attribute - a number telling cybergraphics which attribute of the bitmap should be returned:
CYBRMATTR_XMOD returns bytes per row of the supplied bitmap
CYBRMATTR_BPPIX returns number of bytes per pixel
CYBRMATTR_PIXFMT return the pixel format of the bitmap
CYBRMATTR_WIDTH return width of the bitmap in pixels
CYBRMATTR_HEIGHT return the height in lines
CYBRMATTR_DEPTH returns bits per pixel
CYBRMATTR_ISCYBERGFX returns TRUE if supplied bitmap is a CyberGraphics one
CYBRMATTR_ISLINEARMEM returns TRUE if the related display buffer supports linear memory access
ULONG GetCyberIDAttr(ULONG attribute, ULONG DisplayModeID)
attribute - A number telling cybergraphics which attribute of the displaymode id should be returned:
CYBRIDATTR_PIXFMT return the pixel format of the supplied screenmode id
CYBRIDATTR_WIDTH returns visible width in pixels
CYBRIDATTR_HEIGHT returns visible height in lines
CYBRIDATTR_DEPTH returns bits per pixel
CYBRIDATTR_BPPIX returns bytes per pixel
ULONG ReadRGBPixel(struct RastPort *rp, UWORD x, UWORD y)
LONG WriteRGBPixel(struct RastPort *rp, UWORD x, UWORD y, ULONG pixel)
ULONG ReadPixelArray(IPTR dst, UWORD destx, UWORD desty, UWORD dstmod, struct RastPort *rp, UWORD srcx,
UWORD srcy, UWORD width, UWORD height, UBYTE dstformat)
destRect - pointer to an array of pixels where to write the pixel
data to. The pixel format is specified in DestFormat
(DestX,DestY) - starting point in the destination rectangle
DestMod - The number of bytes per row in the destination rectangle.
RastPort - pointer to a RastPort structure
(SrcX,SrcY) - starting point in the RastPort
(SizeX,SizeY) - size of the rectangle that should be transfered
DestFormat - pixel format in the destination rectangle
Currently supported formats are:
RECTFMT_RGB 3 bytes per pixel, one byte red, one blue
and one byte green component
RECTFMT_RGBA 4 bytes per pixel, one byte red, one blue,
one byte green component and the last
byte is alpha channel information which
is 0 if the board does not support alpha
channel
RECTFMT_ARGB 4 bytes per pixel, one byte red, one blue,
one byte green component and the first
byte is alpha channel information. If the
board does not support alpha channel a
0 is returned for alpha channel information
ULONG WritePixelArray(IPTR src, UWORD srcx, UWORD srcy, UWORD srcmod, struct RastPort *rp, UWORD destx,
UWORD desty, UWORD width, UWORD height, UBYTE srcformat)
ULONG MovePixelArray(UWORD SrcX, UWORD SrcY, struct RastPort *RastPort, UWORD DstX, UWORD DstY,
UWORD SizeX, UWORD SizeY)
ULONG InvertPixelArray(struct RastPort *rp, UWORD destx, UWORD desty, UWORD width, UWORD height)
ULONG FillPixelArray(struct RastPort *rp, UWORD destx, UWORD desty, UWORD width, UWORD height, ULONG pixel)
void DoCDrawMethodTagList(struct Hook *hook, struct RastPort *rp, struct TagItem *tags)
void CVideoCtrlTagList(struct ViewPort *vp, struct TagItem *tags)
IPTR LockBitMapTagList(IPTR bitmap, struct TagItem *tags)
Tags LBMI_WIDTH (ULONG *) - points to a longword which contains the bitmap
width after a successful call
LBMI_HEIGHT (ULONG *) - points to a longword which contains the bitmap
height after a successful call
LBMI_DEPTH (ULONG *) - points to a longword which contains the bitmap
depth after a successful call
LBMI_PIXFMT (ULONG *) - points to a longword which contains the used
pixel format.
Possibly returned colormodels are:
PIXFMT_LUT8
PIXFMT_RGB15
PIXFMT_BGR15
PIXFMT_RGB15PC
PIXFMT_BGR15PC
PIXFMT_RGB16
PIXFMT_BGR16
PIXFMT_RGB16PC
PIXFMT_BGR16PC
PIXFMT_RGB24
PIXFMT_BGR24
PIXFMT_ARGB32
PIXFMT_BGRA32
PIXFMT_RGBA32
LBMI_BYTESPERPIX (ULONG *) - points to a longword which contains the
amount of bytes per pixel data.
LBMI_BYTESPERROW (ULONG *) - points to a longword which contains the
number of bytes per row for one bitmap
line
LBMI_BASEADDRESS (ULONG *) - points to a longword which contains the
bitmap base address. THIS ADDRESS IS ONLY
VALID INSIDE OF THE LOCK/UNLOCKBITMAP
CALL!!!!!!!!!
void UnLockBitMap(IPTR Handle)
void UnLockBitMapTagList(IPTR Handle, struct TagItem *Tags)
ULONG ExtractColor(struct RastPort *RastPort, struct BitMap *SingleMap, ULONG Colour, ULONG sX, ULONG sY,
ULONG Width, ULONG Height)
LONG ScalePixelArray(IPTR srcRect, UWORD SrcW, UWORD SrcH, UWORD SrcMod, struct RastPort *RastPort,
UWORD DestX, UWORD DestY, UWORD DestW, UWORD DestH, UBYTE SrcFormat)
LONG WriteLUTPixelArray(IPTR srcRect, UWORD SrcX, UWORD SrcY, UWORD SrcMod, struct RastPort *rp,
IPTR CTable, UWORD DestX, UWORD DestY, UWORD SizeX, UWORD SizeY, UBYTE CTabFormat)
ULONG WritePixelArrayAlpha(IPTR src, UWORD srcx, UWORD srcy, UWORD srcmod, struct RastPort *rp,
UWORD destx, UWORD desty, UWORD width, UWORD height, ULONG globalalpha)
void BltTemplateAlpha(IPTR src, LONG srcx, LONG srcmod, struct RastPort *rp, LONG destx, LONG desty,
LONG width, LONG height)
cybergraphics.library/AllocCModeListTagList cybergraphics.library/AllocCModeListTagList
NAME
AllocCModeListTagList -- get an exec list with requested modes.
AllocCModeListTags -- Varargs stub for AllocCModeListTagList
SYNOPSIS
result = AllocCModeListTagList( TagItems )
D0 A1
APTR AllocCModeListTagList( struct TagItem * );
result = AllocCModeListTags( Tag1,... )
APTR AllocCModeListTags( Tag Tag1,... );
FUNCTION
Allocates a list structure which contains all requested modes (All nodes
are of type CyberModeNode). See defines for more information about the
structure of this nodes.
INPUTS
TagItems - pointer to an optional tag list which may be used to
control the number of returned modes
TAGS
Tags available are:
CYBRMREQ_MinWidth (ULONG) - The minimum display width to let the user
choose. Default is 320.
CYBRMREQ_MaxWidth (ULONG) - The maximum display width to let the user
choose. Default is 1600.
CYBRMREQ_MinHeight (ULONG) - The minimum display height to let the user
choose. Default is 240.
CYBRMREQ_MaxHeight (ULONG) - The maximum display height to let the user
choose. Default is 1200.
CYBRMREQ_MinDepth (UWORD) - The minimum display depth to let the user
choose. Default is 8.
CYBRMREQ_MaxDepth (UWORD) - The maximum display depth to let the user
choose. Default is 32.
CYBRMREQ_CModelArray (UWORD *) - Array of color models which should be
available for screenmode selection. Currently supported
colormodels are:
PIXFMT_LUT8
PIXFMT_RGB15
PIXFMT_BGR15
PIXFMT_RGB15PC
PIXFMT_BGR15PC
PIXFMT_RGB16
PIXFMT_BGR16
PIXFMT_RGB16PC
PIXFMT_BGR16PC
PIXFMT_RGB24
PIXFMT_BGR24
PIXFMT_ARGB32
PIXFMT_BGRA32
PIXFMT_RGBA32
default is all colormodels available, nothing filtered
RESULT
result - 0 if no modes are available, a pointer to a exec list if there
are modes which fit your needs.
SEE ALSO
FreeCModeList()
�cybergraphics.library/BestCModeIDTagList cybergraphics.library/BestCModeIDTagList
NAME
BestCModeIDTagList -- calculate the best ModeID with given parameters
BestCModeIDTags -- Varags stub for BestCModeIDTagList
SYNOPSIS
ID = BestCModeIDTagList( TagItems )
D0 A0
ULONG BestCModeIDTagList( struct TagItem * );
ID = BestCModeIDTags( Tag1,...)
ULONG BestCModeIDTags( Tag,... );
FUNCTION
Returns the CyberGraphX displaymode ID which fits best for the parameters
supplied in the TagList.
INPUTS
TagItems - pointer to an array of TagItems
TAGS
CYBRBIDTG_Depth (ULONG) - depth the returned ModeID must support
Default is 8
CYBRBIDTG_NominalWidth (UWORD),
CYBRBIDTAG_NominalHeight (UWORD) - desired width and height the ModeID
should have
CYBRBIDTG_MonitorID (ULONG) - if multiple graphics boards are
installed in the system, you can choose
the desired one with this tag
Currently supported boards are:
CVision64 [1]
Piccolo [2]
PicassoII [3]
Spectrum [4]
Domino [5]
RetinaZ3/DraCoAltais [6]
PiccoSD64 [7]
A2410 [8]
CVision3D [13] (V41)
Inferno [14] (V41)
PicassoIV [15] (V41)
CYBRBIDTG_BoardName (STRPTR) - Specify the card name directly. For
example, pass "CVision3D" to get a
CyberVision64/3D board ID
RESULT
ID - id of the best mode to use, or INVALID_ID if a match could
not be found.
BUGS
Older versions return displaymode ids with wrong depth if the
desired color depth is not available.
If you specify very small widths/heights (e.g. 50/20 icon size) this
call returns INVALID_ID instead of the smallest available lowres
ID
�cybergraphics.library/CModeRequestTagList cybergraphics.library/CModeRequestTagList
NAME
CModeRequestTagList -- get screenmode from user using a requester.
CModeRequestTags -- Varargs stub for CModeRequestTagList
SYNOPSIS
result = CModeRequestTagList( Requester, TagItems )
D0 A0 A1
LONG CModeRequestTagList( APTR, struct TagItem * );
result = CModeRequestTags( Requester, Tag1,... )
LONG CModeRequestTags( APTR, Tag,...);
FUNCTION
Prompts the user for input by showing all available CyberGraphX
screenmodes in a requester.
If the user cancels or the system aborts the request, FALSE is returned,
otherwise the displaymode id of the selected screenmode.
INPUTS
Requester - not used currently. You have to set it to NULL!
TagItems - pointer to an optional tag list which may be used to
control features of the requester
TAGS
Tags used for the screen mode requester
CYBRMREQ_Screen (struct Screen *) - Screen on which to open the requester.
default locale will be used.
CYBRMREQ_WinTitle (STRPTR) - Title to use for the requesting window.
CYBRMREQ_OKText (STRPTR) - Label of the positive gadget in the
requester. English default is "OK".
CYBRMREQ_CancelText (STRPTR) - Label of the negative gadget in the
requester. English default is "Cancel".
CYBRMREQ_MinWidth (ULONG) - The minimum display width to let the user
choose. Default is 320.
CYBRMREQ_MaxWidth (ULONG) - The maximum display width to let the user
choose. Default is 1600.
CYBRMREQ_MinHeight (ULONG) - The minimum display height to let the user
choose. Default is 240.
CYBRMREQ_MaxHeight (ULONG) - The maximum display height to let the user
choose. Default is 1200.
CYBRMREQ_MinDepth (UWORD) - The minimum display depth to let the user
choose. Default is 8.
CYBRMREQ_MaxDepth (UWORD) - The maximum display depth to let the user
choose. Default is 32.
CYBRMREQ_CModelArray (UWORD *) - Array of color models which should
be available for screenmode selection. Currently
supported colormodels are:
PIXFMT_LUT8
PIXFMT_RGB15
PIXFMT_BGR15
PIXFMT_RGB15PC
PIXFMT_BGR15PC
PIXFMT_RGB16
PIXFMT_BGR16
PIXFMT_RGB16PC
PIXFMT_BGR16PC
PIXFMT_RGB24
PIXFMT_BGR24
PIXFMT_ARGB32
PIXFMT_BGRA32
PIXFMT_RGBA32
default is all colormodels available, nothing filtered
RESULT
result - 0 if the user cancelled the requester or if something
prevented the requester from opening. If!= 0 the displaymode
id of the selected screenmode is returned.
BUGS
The requester structure is not supported.
NOTES
You should better use asl.library/AslRequest() instead.
�cybergraphics.library/CVideoCtrlTagList cybergraphics.library/CVideoCtrlTagList
NAME
CVideoCtrlTagList -- Control video output
CVideoCtrlTags -- Varargs stub for CVideoCtrlTagList
SYNOPSIS
CVideoCtrlTagList( ViewPort, TagItems )
A0 A1
void CVideoCtrlTagList( struct ViewPort *, struct TagItem * );
CVideoCtrlTags( ViewPort, Tag1,... )
void CVideoCtrlTags( struct ViewPort *, Tag tag1,... );
FUNCTION
This function controls the video output of the gfx board to which the
specified ViewPort belongs to.
INPUTS
ViewPort - pointer to a ViewPort of a CyberGraphX screen
TagItems - taglist to control operation
TAGS
SETVC_DPMSLevel (ULONG) Set the DPMS level for the specified viewport
Supported levels are:
DPMS_ON Full operation
DPMS_STANDBY Optional state of minimal power reduction
DPMS_SUSPEND Significant reduction of power consumption
DPMS_OFF Lowest level of power consumption
EXAMPLE
CVideoCtrlTags (&Scr->ViewPort,SETVC_DPMSLevel,DPMS_OFF,TAG_DONE);
/* set DPMS level */
NOTES
Some DPMS levels are not implemented for certain graphics cards
�cybergraphics.library/DoCDrawMethodTagList cybergraphics.library/DoCDrawMethodTagList
NAME
DoCDrawMethodTagList -- Do the given hook for the supplied rastport
DoCDrawMethodTags -- Varargs stub for DoCDrawMethodTagList
SYNOPSIS
DoCDrawMethodTagList( Hook, RastPort, TagItems )
A0 A1 A2
void DoCDrawMethodTagList( struct Hook *, struct RastPort *,
struct TagItem * )
DoCDrawMethodTags( Hook, RastPort, Tag1,... )
void DoCDrawMethodTags( struct Hook *, struct RastPort *,
Tag1,... )
FUNCTION
This function will call the given hook for the given rastport. Is is
mainly used to do direct bitmap modifications in a locked graphics
environment. You have to support ALL known color models, so only use
this call if you really need it!!
INPUTS
Hook - pointer to callback hook which will be called
with object == (struct RastPort *)
and message == [ (APTR) memptr,
(ULONG) offsetx, (ULONG) offsety,
(ULONG) xsize, (ULONG) ysize,
(UWORD) bytesperrow, (UWORD) bytesperpix,
(UWORD) colormodel]
Where colormodel is one of the following:
PIXFMT_LUT8
PIXFMT_RGB15
PIXFMT_BGR15
PIXFMT_RGB15PC
PIXFMT_BGR15PC
PIXFMT_RGB16
PIXFMT_BGR16
PIXFMT_RGB16PC
PIXFMT_BGR16PC
PIXFMT_RGB24
PIXFMT_BGR24
PIXFMT_ARGB32
PIXFMT_BGRA32
PIXFMT_RGBA32
RastPort- A pointer to a cybergraphics RastPort
TagItems - optional taglist, currently not used. Set it to NULL!
NOTES
Use this call only if you want high speed. Keep in mind that you have
to handle all color models! Do not use ANY os functions in your hook.
They would cause unpredictable results.
BUGS
In previous autodocs, the bytesperrow message field was described as
an (ULONG) which in fact was an (UWORD).
SEE ALSO
LockBitMap(), LockBitMapTagList()
�cybergraphics.library/FreeCModeList cybergraphics.library/FreeCModeList
NAME
FreeCModeList -- frees a previously allocated ModeList
SYNOPSIS
FreeCModeList( ModeList );
A0
void FreeCModeList( struct List * );
FUNCTION
frees all data which was previously allocated by AllocCModeListTagList()
INPUTS
ModeList - a list structure which contains all the mode data.
SEE ALSO
AllocCModeListTagList()
�cybergraphics.library/GetCyberMapAttr cybergraphics.library/GetCyberMapAttr
NAME
GetCyberMapAttr -- Returns information about a cybergraphics bitmap
SYNOPSIS
value = GetCyberMapAttr( BitMap, Attribute );
D0 A0 D0
ULONG GetCyberMapAttr( struct BitMap *, ULONG );
FUNCTION
Gets information about an extended cybergraphics bitmap.
This function should be used instead of making any assumptions about
fields in the bitmap structure. This will provide future
compatibility.
INPUTS
BitMap - pointer to a cybergraphics bitmap structure
Attribute - a number telling cybergraphics which attribute
of the bitmap should be returned:
CYBRMATTR_XMOD returns bytes per row of the
supplied bitmap
CYBRMATTR_BPPIX returns number of bytes per pixel
CYBRMATTR_PIXFMT return the pixel format of the
bitmap
CYBRMATTR_WIDTH return width of the bitmap in
pixels
CYBRMATTR_HEIGHT return the height in lines
CYBRMATTR_DEPTH returns bits per pixel
CYBRMATTR_ISCYBERGFX returns TRUE if supplied bitmap is
a CyberGraphX one
CYBRMATTR_ISLINEARMEM returns TRUE if the related display
buffer supports linear memory access
NOTES
Unknown attributes are reserved for future use, and return (-1L).
You should know what you are doing if you call this function!
Always use the CYBRMATTR_ISCYBERGFX attribute first to check if the
bitmap is a CyberGraphX one.
SEE ALSO
graphics.library/GetBitMapAttr()
�cybergraphics.library/GetCyberIDAttr cybergraphics.library/GetCyberIDAttr
NAME
GetCyberIDAttr -- Returns information about a cybergraphics id
SYNOPSIS
value = GetCyberIDAttr( Attribute, DisplayModeID )
D0 D0 D1
ULONG GetCyberIDAttr( ULONG, ULONG );
FUNCTION
Returns information about a specified displaymode id.
INPUTS
Attribute - A number telling cybergraphics which attribute
of the displaymode id should be returned:
CYBRIDATTR_PIXFMT return the pixel format of the supplied
screenmode id
CYBRIDATTR_WIDTH returns visible width in pixels
CYBRIDATTR_HEIGHT returns visible height in lines
CYBRIDATTR_DEPTH returns bits per pixel
CYBRIDATTR_BPPIX returns bytes per pixel
DisplayModeID - CyberGraphX displaymode id
NOTES
Unknown attributes are reserved for future use, and return (-1L).
You should know what you are doing if you call this function!
Don't apply it on a non cybergraphics displaymode!
�cybergraphics.library/IsCyberModeID cybergraphics.library/IsCyberModeID
NAME
IsCyberModeID -- returns whether supplied ModeID is a cybergraphics id
SYNOPSIS
result = IsCyberModeID( DisplayModeID )
D0 D0
BOOL IsCyberModeID( ULONG );
FUNCTION
returns whether the supplied ModeID is a cybergraphics.library mode
identifier (TRUE) or not (FALSE).
INPUTS
DisplayModeID -- a 32-bit display identifier.
RESULT
result - Flag to indicate if DisplayModeID is a CyberGraphX id
�cybergraphics.library/ExtractColor cybergraphics.library/ExtractColor
NAME
ExtractColor -- Extract the specified colour/CLUT value from a given
CyberGraphX RastPort into a single plane bitmap starting at
a certain x,y location and using the specified width and
height. (V41)
SYNOPSIS
result = ExtractColor(RastPort,SingleMap,Colour,sX,sY, Width, Height)
D0 A0 A1 D0 D1 D2 D3 D4
LONG ExtractColor(struct RastPort *,struct BitMap *,ULONG, ULONG,
ULONG, ULONG, ULONG );
FUNCTION
ExtractColor -- Extract the specified colour/CLUT value from a given
CyberGraphX RastPort into a single plane bitmap starting at
a certain x,y location and using the specified width and
height. Use this function if you want to create masks.
(V41)
INPUTS
RastPort - pointer to a CyberGraphX RastPort structure
SingleMap - planar destination bitmap that has at least a depth of
one and the minimum width and height specified.
Colour - the color that should be extracted in AARRGGBB format for
true color rastports or in indexed mode for CLUT rastports.
The ULONG coding is as follows (for rgb screens):
AA - 8-bit alpha channel component
(set it to 00 if you do not use it!)
RR - 8-bit red component of the pixel
GG - 8-bit green component
BB - 8-bit blue component
For CLUT rastports only the lowest byte is used as an index
value to a 256 colour lookup table
sX,sY - starting point in the RastPort that should be analyzed
Width,Height - size of the rectangle that should be analyzed
RESULT
result - returns TRUE if colour could be extracted, FALSE if not
NOTES
This call was a no-op in very early revisions of cybergraphics v41
�cybergraphics.library/FillPixelArray cybergraphics.library/FillPixelArray
NAME
FillPixelArray -- fill a rectangular area with the supplied ARGB value
starting at a specified x,y location and continuing through to another
x,y location within a certain RastPort
SYNOPSIS
count = FillPixelArray(RastPort,DestX, DestY,SizeX,SizeY,ARGB)
D0 A1 D0:16 D1:16 D2:16 D3:16 D4:32
LONG FillPixelArray( struct RastPort *, UWORD, UWORD,
UWORD, UWORD, ULONG );
FUNCTION
For each pixel in a rectangular region, write the supplied color value
into the bitmap used to describe a particular rastport.
INPUTS
RastPort - pointer to a RastPort structure
(DestX,DestY) - starting point in the RastPort
(SizeX,SizeY) - size of the rectangle that should be transfered
ARGB - the desired color in AARRGGBB format for true color rastports
or in indexed mode for CLUT rastports. Every component
uses 8 bits in the supplied longword. The coding is as
follows (for rgb screens):
AA - 8-bit alpha channel component
(set it to 00 if you do not use it!)
RR - 8-bit red component of the pixel
GG - 8-bit green component
BB - 8-bit blue component
For CLUT rastports only the blue component is used as an
index value to a 256 colour lookup table
RESULT
count will be set to the number of pixels plotted
NOTES
This function should only be used on screens depths > 8 bits in
cybergraphics versions prior v41.
BUGS
The returned count value is wrong up to and including v41 of the
cybergraphics.library
SEE ALSO
InvertPixelArray()
�cybergraphics.library/InvertPixelArray cybergraphics.library/InvertPixelArray
NAME
InvertPixelArray -- invert a rectangular area
SYNOPSIS
count = InvertPixelArray(RastPort,DestX, DestY,SizeX,SizeY)
D0 A1 D0:16 D1:16 D2:16 D3:16
LONG InvertPixelArray( struct RastPort *, UWORD, UWORD,
UWORD,UWORD );
FUNCTION
Invert each pixel in a rectangular region.
INPUTS
RastPort - pointer to a RastPort structure
(DestX,DestY) - starting point in the RastPort
(SizeX,SizeY) - size of the rectangle that should be transfered
RESULT
count will be set to the number of pixels plotted
NOTES
This function should only be used on screens depths > 8 bits with
cybergraphics versions prior v41.
BUGS
The count value returned is totally wrong.
SEE ALSO
FillPixelArray()
�cybergraphics.library/LockBitmapTagList cybergraphics.library/LockBitMapTagList
NAME
LockBitMapTagList -- Lock supplied BitMap for a short amount of time
to allow direct memory access
SYNOPSIS
handle = LockBitmapTagList(bitmap,tags);
D0 A0 A1
APTR LockBitMapTagList( APTR,struct TagItem * );
APTR LockBitMapTags( APTR,Tag1,... );
FUNCTION
INPUTS
bitmap - pointer to a CyberGraphX bitmap pointer. please check if it is
a cybermap by calling GetCyberMapAttr() first.
tags - pointer to a mandatory taglist which's tagdata pointer fields
contain valid longwords after a successful call.
TAGS
Tags used for the screen mode requester
LBMI_WIDTH (ULONG *) - points to a longword which contains the bitmap
width after a successful call
LBMI_HEIGHT (ULONG *) - points to a longword which contains the bitmap
height after a successful call
LBMI_DEPTH (ULONG *) - points to a longword which contains the bitmap
depth after a successful call
LBMI_PIXFMT (ULONG *) - points to a longword which contains the used
pixel format.
Possibly returned colormodels are:
PIXFMT_LUT8
PIXFMT_RGB15
PIXFMT_BGR15
PIXFMT_RGB15PC
PIXFMT_BGR15PC
PIXFMT_RGB16
PIXFMT_BGR16
PIXFMT_RGB16PC
PIXFMT_BGR16PC
PIXFMT_RGB24
PIXFMT_BGR24
PIXFMT_ARGB32
PIXFMT_BGRA32
PIXFMT_RGBA32
LBMI_BYTESPERPIX (ULONG *) - points to a longword which contains the
amount of bytes per pixel data.
LBMI_BYTESPERROW (ULONG *) - points to a longword which contains the
number of bytes per row for one bitmap
line
LBMI_BASEADDRESS (ULONG *) - points to a longword which contains the
bitmap base address. THIS ADDRESS IS ONLY
VALID INSIDE OF THE LOCK/UNLOCKBITMAP
CALL!!!!!!!!!
RESULT
handle - 0 if the bitmap could not be locked,!= 0 it contains a handle
which should be passed to UnLockBitMap afterwards
NOTES
Only use this call if you really NEED the rendering speed, DON'T lock the
bitmap longer than for one frame. DON'T use any library calls while the
bitmap is locked! This function is considered low level.
BUGS
The LBMI_DEPTH tagitem pointer will always contain 8 even for deeper
bitmaps. Use GetCyberMapAttr() or graphics.library/GetBitMapAttr() to
get the correct depth.
SEE ALSO
UnLockBitMap(), UnLockBitMapTagList()
�cybergraphics.library/MovePixelArray cybergraphics.library/MovePixelArray
NAME
MovePixelArray -- move the color values of a rectangular area of
pixels starting at a specified x,y location and continuing through
to another x,y location within a certain RastPort
SYNOPSIS
count = MovePixelArray(SrcX, SrcY, RastPort,DstX, DstY,SizeX, SizeY)
D0 D0:16 D1:16 A1 D2:16 D3:16 D4:16 D5:16
LONG MovePixelArray(UWORD,UWORD,struct RastPort *,UWORD,UWORD,UWORD,
UWORD)
FUNCTION
For each pixel in a rectangular region, move the pixel value from a
specified source to a specified destination
INPUTS
(SrcX,SrcY) - starting point in the source rectangle
RastPort - pointer to a RastPort structure
(DestX,DestY) - starting point in the destination rectangle
(SizeX,SizeY) - size of the rectangle that should be transfered
RESULT
count will be set to the number of pixels moved
NOTES
This function should only be used on screens depths > 8 bits with
cybergraphics versions up to v40.
The blitter can be used to move the data if the bitmap is in display
memory. This is why you should use this call.
BUGS
The count value returned is totally wrong.
SEE ALSO
FillPixelArray(), InvertPixelArray(),
graphics.library/BltBitMapRastPort()
�cybergraphics.library/ReadPixelArray cybergraphics.library/ReadPixelArray
NAME
ReadPixelArray -- Read the color values of a rectangular array of
pixels starting at a specified x,y location and continuing through
to another x,y location within a certain RastPort
SYNOPSIS
count = ReadPixelArray(destRect,DestX,DestY,DestMod,RastPort,SrcX,
D0 A0 D0:16 D1:16 D2:16 A1 D3:16
SrcY,SizeX,SizeY,DestFormat)
D4:16 D5:16 D6:16 D7
LONG ReadPixelArray(APTR,UWORD,UWORD,UWORD,struct RastPort *,UWORD,
UWORD,UWORD,UWORD,UBYTE)
FUNCTION
For each pixel in a rectangular region, write the color value to a
linear array of color values from the bitmap used to describe a
particular rastport.
INPUTS
destRect - pointer to an array of pixels where to write the pixel
data to. The pixel format is specified in DestFormat
(DestX,DestY) - starting point in the destination rectangle
DestMod - The number of bytes per row in the destination rectangle.
RastPort - pointer to a RastPort structure
(SrcX,SrcY) - starting point in the RastPort
(SizeX,SizeY) - size of the rectangle that should be transfered
DestFormat - pixel format in the destination rectangle
Currently supported formats are:
RECTFMT_RGB 3 bytes per pixel, one byte red, one blue
and one byte green component
RECTFMT_RGBA 4 bytes per pixel, one byte red, one blue,
one byte green component and the last
byte is alpha channel information which
is 0 if the board does not support alpha
channel
RECTFMT_ARGB 4 bytes per pixel, one byte red, one blue,
one byte green component and the first
byte is alpha channel information. If the
board does not support alpha channel a
0 is returned for alpha channel information
RESULT
count will be set to the number of pixels read
NOTES
This function should only be used on screens depths > 8 bits.
BUGS
The count value returned is totally wrong.
SEE ALSO
WritePixelArray(), graphics.library/ReadPixelArray8()
�cybergraphics.library/ReadRGBPixel cybergraphics.library/ReadRGBPixel
NAME
ReadRGBPixel -- Reads a pixel from a specified location
SYNOPSIS
color = ReadRGBPixel(RastPort,x,y )
D0 A1 D0 D1
ULONG ReadRGBPixel(struct RastPort *,UWORD,UWORD);
FUNCTION
Read the alpha,red,green & blue 8-bit color components of the pixel at
a specified x,y location within a certain RastPort
INPUTS
rp - pointer to a RastPort structure
x,y - the coordinates of the pixel
RESULT
color - the desired color in AARRGGBB format. Every component
allocates 8 bits in the returned longword. The coding is as
follows:
AA - 8-bit alpha-channel component
(boards which do not have an alpha channel return 00)
RR - 8-bit red component of the pixel
GG - 8-bit green component
BB - 8-bit blue component
NOTES
This function should only be used on screens depths > 8 bits. Use
ReadPixel() on 8 bit screens!
SEE ALSO
WriteRGBPixel()
�cybergraphics.library/ScalePixelArray cybergraphics.library/ScalePixelArray
NAME
ScalePixelArray -- Scale the colors values of a rectangular array of
pixels starting at a specified x,y location and continuing through
to another x,y location within a certain RastPort (V41)
SYNOPSIS
count = ScalePixelArray(srcRect,SrcW,SrcH,SrcMod,RastPort,DestX,
D0 A0 D0:16 D1:16 D2:16 A1 D3:16
DestY,DestW,DestH,SrcFormat)
D4:16 D5:16 D6:16 D7
LONG ScalePixelArray(APTR,UWORD,UWORD,UWORD,struct RastPort *,UWORD,
UWORD,UWORD,UWORD,UBYTE)
FUNCTION
For each pixel in a rectangular region, scale the color values from a
linear array of color values into the bitmap used to describe a
particular rastport.
INPUTS
srcRect - pointer to an array of pixels from which to fetch the
pixel data. The pixel format is specified in SrcFormat
(SrcW,SrcH) - Width and Height of the source rectangle
SrcMod - The n umber of bytes per row in the source rectangle.
RastPort - pointer to a RastPort structure
(DestX,DestY) - starting point in the RastPort
(DestW,DestH) - size of the destination area
SrcFormat - pixel format in the source rectangle
Currently supported formats are:
RECTFMT_RGB 3 bytes per pixel, one byte red, one blue
and one byte green component
RECTFMT_RGBA 4 bytes per pixel, one byte red, one blue,
one byte green component and the last
byte is alpha channel information. If you
do not use alpha channel set this byte to
0!!!
RECTFMT_ARGB 4 bytes per pixel, one byte red, one blue,
one byte green component and the first
byte is alpha channel information. If you
do not use alpha channel set this byte to
0!!!
RECTFMT_LUT8 1 byte per pixel, specifying the pen
number. On screen depths > 8 bits the
data is converted using the actual color
lookup table.
RECTFMT_GREY8 1 byte per pixel, specifying grey scale
value.
RESULT
count will be set to the number of pixels plotted
NOTES
Up to v40, this function only worked on screens depths > 8 bits.
You may specify RECTFMT_LUT8 on 8bit screens, too now if v41 is
available
BUGS
Very early v40 revision did not support RECTFMT_LUT8 and
RECTFMT_GREY8.
Scaling is not very accurate. If you need high quality, use
graphics.library/BitMapScale() instead or custom code.
The count value returned is totally wrong.
SEE ALSO
graphics.library/BitMapScale()
�cybergraphics.library/WriteLUTPixelArray cybergraphics/WriteLUTPixelArray
NAME
WriteLUTPixelArray -- write the color value generated from a given
color table of a rectangular array of pixels starting at a specified
x,y location and continuing through to another x,y location within
a certain RastPort (V41)
SYNOPSIS
count = WriteLUTPixelArray(srcRect,SrcX,SrcY,SrcMod,RastPort,
D0 A0 D0:16 D1:16 D2:16 A1
CTable,DestX,DestY,SizeX,SizeY,CTabFormat)
A2 D3:16 D4:16 D5:16 D6:16 D7
LONG WriteLUTPixelArray(APTR,UWORD,UWORD,UWORD,struct RastPort *,APTR,
UWORD, UWORD,UWORD,UWORD,UBYTE)
FUNCTION
For each pixel in a rectangular region, write the color value
generated with a given color lookup table from a linear array of
indexed pixel values into the bitmap used to describe a particular
rastport.
INPUTS
srcRect - pointer to an array of pixels from which to fetch the
CLUT data. Pixels are specified in bytes, 8bits/pixel.
(SrcX,SrcY) - starting point in the source rectangle
SrcMod - The number of bytes per row in the source rectangle.
RastPort - pointer to a RastPort structure
CTable - pointer to the color table using the format specified
with CTabFormat
(DestX,DestY) - starting point in the RastPort
(SizeX,SizeY) - size of the rectangle that should be transfered
CTabFormat - color table format in the source rectangle
Currently supported formats are:
CTABFMT_XRGB8 - CTable is a pointer to a ULONG table
which contains 256 entries. Each entry specifies the
rgb colour value for the related index. The format
is XXRRGGBB.
XX - unused
RR - 8-bit red component of the pixel
GG - 8-bit green component
BB - 8-bit blue component
RESULT
count will be set to the number of pixels plotted
NOTES
Does only work on rastports with depth > 8bits
BUGS
The count value returned is totally wrong.
With cgxsystem.library up to version 41.19, the call returns
immediately with CTABFMT_XRGB8 due to a bug in the code
SEE ALSO
ReadPixelArray(), WritePixelArray(),
graphics.library/WritePixelArray8()
�cybergraphics.library/WritePixelArray cybergraphics.library/WritePixelArray
NAME
WritePixelArray -- write the color value of a rectangular array of
pixels starting at a specified x,y location and continuing through
to another x,y location within a certain RastPort
SYNOPSIS
count = WritePixelArray(srcRect,SrcX,SrcY,SrcMod,RastPort,DestX,
D0 A0 D0:16 D1:16 D2:16 A1 D3:16
DestY,SizeX,SizeY,SrcFormat)
D4:16 D5:16 D6:16 D7
LONG WritePixelArray(APTR,UWORD,UWORD,UWORD,struct RastPort *,UWORD,
UWORD,UWORD,UWORD,UBYTE)
FUNCTION
For each pixel in a rectangular region, write the color value from a
linear array of color values into the bitmap used to describe a
particular rastport.
INPUTS
srcRect - pointer to an array of pixels from which to fetch the
pixel data. The pixel format is specified in SrcFormat
(SrcX,SrcY) - starting point in the source rectangle
SrcMod - The number of bytes per row in the source rectangle.
RastPort - pointer to a RastPort structure
(DestX,DestY) - starting point in the RastPort
(SizeX,SizeY) - size of the rectangle that should be transfered
SrcFormat - pixel format in the source rectangle
Currently supported formats are:
RECTFMT_RGB 3 bytes per pixel, one byte red, one blue
and one byte green component
RECTFMT_RGBA 4 bytes per pixel, one byte red, one
blue, one byte green component and the
last byte is alpha channel information.
If you do not use alpha channel set this
byte to 0!!!
RECTFMT_ARGB 4 bytes per pixel, one byte red, one
blue, one byte green component and the
first byte is alpha channel information.
If you do not use alpha channel set this
byte to 0!!!
RECTFMT_LUT8 1 byte per pixel, specifying the pen
number. On screen depths > 8 bits the
data is converted using the actual color
lookup table.
RECTFMT_GREY8 1 byte per pixel, specifying grey scale
value.
RESULT
count will be set to the number of pixels plotted
NOTES
Only RECTFMT_LUT8 can be used on screen depths <= 8 bits.
For > 8 bit rastport RECTFMT_LUT8 uses the actual colormap "attached"
to the bitmap. If the bitmap is a friend bitmap of a screen bitmap
or the screen bitmap itself, it uses the screen's viewport colormap.
BUGS
The count value returned is totally wrong.
SEE ALSO
ReadPixelArray(), WriteLUTPixelArray(),
graphics.library/WritePixelArray()
�cybergraphics.library/WriteRGBPixel cybergraphics.library/WriteRGBPixel
NAME
WriteRGBPixel -- Writes a pixel to a specified location
SYNOPSIS
error = WriteRGBPixel(RastPort,x,y,color)
D0 A1 D0 D1 D2
ULONG WriteRGBPixel(struct RastPort *,UWORD,UWORD,ULONG);
FUNCTION
Write the alpha,red,green and blue 8-bit color component of the given
color to a specified x,y location within a certain RastPort
INPUTS
rp - pointer to a RastPort structure
x,y - the coordinates of the pixel
color - the desired color in AARRGGBB format. Every component
allocates 8 bits of the returned longword. The coding is as
follows:
AA - 8-bit alpha channel component
(set it to 00 if you dont want to use it!)
RR - 8-bit red component of the pixel
GG - 8-bit green component
BB - 8-bit blue component
RESULT
error = 0 if pixel successfully changed
= -1 if (x,y) is outside the rastport
NOTES
This function should only be used on screens depths > 8 bits. Use
WritePixel() on 8 bit screens!
SEE ALSO
ReadRGBPixel(), graphics.library/WritePixel()
�cybergraphics.library/UnLockBitmap cybergraphics.library/UnLockBitMap
NAME
UnLockBitMap -- Unlock the previously locked CyberGraphX BitMap
SYNOPSIS
UnLockBitmap( Handle )
A0
void UnLockBitMap( APTR );
FUNCTION
Unlock the previously locked CyberGraphX BitMap
INPUTS
handle - handle to the previously locked BitMap
SEE ALSO
LockBitMapTagList()
�cybergraphics.library/UnLockBitmapTagList cybergraphics/UnLockBitMapTagList
NAME
UnLockBitMapTagList -- Unlock the previously locked CyberGraphX BitMap
UnLockBitMapTags -- Varargs stub for UnLockBitMapTagList
SYNOPSIS
UnLockBitmapTagList( Handle, Tags )
A0 A1
void UnLockBitMapTagList( APTR, struct TagItem * );
void UnLockBitMapTags( APTR, Tag1,... );
FUNCTION
Unlock the previously locked CyberGraphX BitMap
INPUTS
handle - handle to the previously locked BitMap
Tags - pointer to a mandatory taglist
TAGS
UBMI_UPDATERECTS (struct RectList *) - pointer to a rectlist which
contains rectangles that should be updated. This is needed for
cards that don't have a linear display memory address space
The RectList structure looks like this:
struct RectList
{
ULONG rl_num; // no. of rects in this list
struct RectList *rl_next; // pointer to next list
struct Rectangle rect1; // This is the first
.. // rectangle followed by
.. // rl_num-1 rectangles
..
}
UBMI_REALLYUNLOCK (BOOL) - Specifies whether bitmap should really be
unlocked (TRUE) or not (FALSE) in case you just want to update
certain rectangles and unlock later.
BUGS
Very early v40 revisions did not support this call
SEE ALSO
LockBitMapTagList(), UnLockBitMap()
�