English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 06 May 2023, 01:37   #1
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
SetAPen returns wrong color.

Hi,
I am a bit confused and can't figure it out.

So when I am checking the WB colors in the Prefs->Palette
I see these colors:
0 - grey, 1-black, 2-white, 3-blue, 4-red, 5-green etc..



In my program I would like to use for example PEN 4 and 5
to draw red or green rectangle. So I am using in my code:

Code:
SetAPen(&APP_pubscreen->RastPort, 4);
RectFill(APP_window->RPort, 0, 0, arg_win_size_x, arg_win_size_y);
Before I init the window like this:

Code:
APP_pubscreen = LockPubScreen(NULL);

          APP_window = OpenWindowTags(NULL, 
                                                  WA_Left, arg_win_pos_x, 
                                                  WA_Top, arg_win_pos_y, 
                                                  WA_Width, window_width, 
                                                  WA_Height, window_height, 
                                                  WA_PubScreen, (ULONG)APP_pubscreen,                                             
                                                  WA_Flags, WFLG_ACTIVATE, 
                                                  WA_IDCMP, IDCMP_REFRESHWINDOW,
                                                  WA_Gadgets, (ULONG)G_gadgets[GID_GADGETS_LIST],
                                                  TAG_END);
But the result color for pen 4 or 5 is ORANGE COLOR instead of red or green (according to this color map)
For example when I am testing color 0-3 the result are OK - I mean I got grey, black, white and blue rectangles.
The numbers above 3 are mismatch.

My goal is to let user select a pen color for online and offline status (by TOOLTYPES).
So as the every user can have different settings I thought this is the best way to do it.
But that PEN numbers are mismatch.
mateusz_s is offline  
Old 06 May 2023, 01:57   #2
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,085
Been a while since I did any of that, but this might help:
Code:
// intuition/screens.h
#define DETAILPEN	 (0x0000)	/* compatible Intuition rendering pens	*/
#define BLOCKPEN	 (0x0001)	/* compatible Intuition rendering pens	*/
#define TEXTPEN		 (0x0002)	/* text on background			*/
#define SHINEPEN	 (0x0003)	/* bright edge on 3D objects		*/
#define SHADOWPEN	 (0x0004)	/* dark edge on 3D objects		*/
#define FILLPEN		 (0x0005)	/* active-window/selected-gadget fill	*/
#define FILLTEXTPEN	 (0x0006)	/* text over FILLPEN			*/
#define BACKGROUNDPEN	 (0x0007)	/* always color 0			*/
#define HIGHLIGHTTEXTPEN (0x0008)	/* special color text, on background	*/
/* New for V39, only present if DRI_VERSION >= 2: */
#define BARDETAILPEN	 (0x0009)	/* text/detail in screen-bar/menus */
#define BARBLOCKPEN	 (0x000A)	/* screen-bar/menus fill */
#define BARTRIMPEN	 (0x000B)	/* trim under screen-bar */

...

struct DrawInfo* p_info = GetScreenDrawInfo(p_screen); 
UBYTE pen_x = p_info->dri_Pens[SHADOWPEN];
SetAPen(p_rport,pen_x);
a/b is online now  
Old 06 May 2023, 09:38   #3
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,041
Quote:
Originally Posted by mateusz_s View Post
Code:
SetAPen(&APP_pubscreen->RastPort, 4);
RectFill(APP_window->RPort, 0, 0, arg_win_size_x, arg_win_size_y);
Look carefully at this piece of code, then you should see it yourself: you set the pen of the screen's RastPort and then draw into the window's RastPort.

You always have to use the same RastPort. Use that of the window. The screen is taboo (except for reading).
thomas is offline  
Old 06 May 2023, 11:27   #4
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
Quote:
Originally Posted by thomas View Post
Look carefully at this piece of code, then you should see it yourself: you set the pen of the screen's RastPort and then draw into the window's RastPort.

You always have to use the same RastPort. Use that of the window. The screen is taboo (except for reading).
Right I messed up here

But after correction:
Code:
SetAPen(APP_window->RPort, 4);
RectFill(APP_window->RPort, 0, 0, arg_win_size_x, arg_win_size_y);
I should get color RED (PEN=4) according to this WB color map.
But instead I get some DEEP BLUE color.
If I set PEN=5 then I got MAROON color that is not even in this palette..

Its like my window have different color map, but it is just a window on public WB screen so I think it should share its palette
mateusz_s is offline  
Old 06 May 2023, 12:07   #5
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
ps.
I also noticed in another application called ScreenTime if I set there a PEN=4
it also gives that DEEP BLUE color instead of red. So maybe this is a System issue?
But I tested on AOS3.2, 3.1 - I dont know so maybe its the way it works.

ObtainBestPen work good in this case actually it can be a replacement or aditional option.
mateusz_s is offline  
Old 06 May 2023, 13:14   #6
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,041
Palette prefs sets the colors of the first four and the last four pens of the screen, not the first eight pens. So in order to get what Palette prefs suggests, you have to set the depth of your Workbench screen to 3 (8 colors).
thomas is offline  
Old 06 May 2023, 15:20   #7
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
Quote:
Originally Posted by thomas View Post
Palette prefs sets the colors of the first four and the last four pens of the screen, not the first eight pens. So in order to get what Palette prefs suggests, you have to set the depth of your Workbench screen to 3 (8 colors).
ooohh, ok, now it makes sense, thanks for clearing it up
mateusz_s 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
shenandoah returns!!! starlord project.aGTW 103 20 March 2024 17:22
Color Saturation and Color Tint/Hue Retro-Nerd support.WinUAE 22 02 August 2018 10:38
Color wrong mritter0 Coders. C/C++ 8 02 April 2014 16:15
Printing in color with WinUAE on color laser source support.Apps 7 14 April 2013 00:32
ISO true color to 256 color algorithm Lord Riton Coders. General 19 15 April 2011 17:49

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 12:13.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09582 seconds with 13 queries