Commit 58cdca05 authored by devill.tamachan's avatar devill.tamachan

[追加] ビットマップビューの256色カスタムパレット

parent cf293bea
......@@ -42,6 +42,7 @@ void Make8bitBITMAPINFOHEADER(LPBITMAPINFOHEADER lpbi, LONG w, LONG h);
//#include "tamascrlu64v.h"
#define CUSTOMPALLET 10
#include "BZSubView.h"
......@@ -64,6 +65,7 @@ public:
COMMAND_RANGE_HANDLER_EX(ID_BMPVIEW_8BITCOLOR, ID_BMPVIEW_32BITCOLOR, OnBmpViewColorWidth)
COMMAND_ID_HANDLER_EX(ID_BMPVIEW_ADDRESSTOOLTIP, OnBmpViewAddressTooltip)
COMMAND_RANGE_HANDLER_EX(ID_BMPVIEW_PALETTE_BZ, ID_BMPVIEW_PALETTE_SAFETY, OnPalletMode)
COMMAND_RANGE_HANDLER_EX(ID_BMPVIEW_CUSTOMPALETTE_START, ID_BMPVIEW_CUSTOMPALETTE_END, OnPalletModeCustom)
CHAIN_MSG_MAP(CTamaScrollWindowU64VImpl<CBZBmpView2>)
END_MSG_MAP()
......@@ -165,6 +167,21 @@ public:
if(options.bAddressTooltip)
pMenu.CheckMenuItem(ID_BMPVIEW_ADDRESSTOOLTIP, MF_BYCOMMAND | MF_CHECKED);
int i=0;
pallets.RemoveAll();
WTL::CFindFile find;
if(find.FindFile(GetModulePath(_T("Pallets\\*.apl"))))
{
do
{
if(find.IsDots() || find.IsDirectory())continue;
//if(i==0)pMenu.AppendMenu(MF_SEPARATOR);
pMenu.AppendMenu(options.lastPalletName==find.GetFileName() && options.nBmpPallet>=CUSTOMPALLET ? MF_STRING | MF_CHECKED : MF_STRING, ID_BMPVIEW_CUSTOMPALETTE_START+i, find.GetFileName());
i++;
pallets.Add(find.GetFilePath());
} while(find.FindNextFile());
}
WTL::CPoint pt;
GetCursorPos(&pt);
pMenu.TrackPopupMenu(0, pt.x, pt.y, m_hWnd);
......@@ -344,6 +361,43 @@ public:
UpdateWindow();
}
void OnPalletModeCustom(UINT uNotifyCode, int nID, CWindow wndCtl)
{
int i = nID - ID_BMPVIEW_CUSTOMPALETTE_START;
if(i<pallets.GetCount())
{
options.nBmpPallet = i+CUSTOMPALLET;
options.nBmpColorWidth = 8;
}
//GetMainFrame()->CreateClient();
OnInitialUpdate();
Invalidate();
UpdateWindow();
}
void LoadAplPallet256(DWORD *pRGB, LPCTSTR path)
{
FILE *fp = _wfopen(path, L"rb");
if(fp==NULL)return;
char sig[16];
if(fread(sig, 1, 6, fp)!=6)goto err_LoadAplPallet256;
sig[6]=NULL;
if(strcmp(sig, "AZPPAL")!=0)goto err_LoadAplPallet256;
WORD w=0;
if(fread(&w, 1, 1, fp)!=1 || w!=0)goto err_LoadAplPallet256;
w=0;
if(fread(&w, 1, 2, fp)!=2 || w<256)goto err_LoadAplPallet256;
for(int i=0;i<w && i<256;i++)
{
if(fread(pRGB, 1, 4, fp)!=4)goto err_LoadAplPallet256;
pRGB++;
}
options.lastPalletName=PathFindFileName(path);
err_LoadAplPallet256:
fclose(fp);
}
CBZBmpView2()
{
m_lpbi = NULL;
......@@ -369,6 +423,8 @@ private:
BOOL bFirst;//for OnInitialUpdate
BOOL bEnable;
CAtlArray<CString> pallets;
public:
CBZView* GetBZView()
......@@ -418,11 +474,37 @@ public:
ATLTRACE("cBmpY64(%I64u) = dwTotal(%I64u) / (UINT64)(options.nBmpWidth(%d) * (options.nBmpColorWidth(%d)/8))\n", m_cBmpY64, dwTotal, options.nBmpWidth, options.nBmpColorWidth);
Make8bitBITMAPINFOHEADER(m_lpbi, options.nBmpWidth, 1/*top-down DIB*/);
if(options.nBmpPallet>=CUSTOMPALLET && pallets.GetCount()==0)
{
pallets.RemoveAll();
WTL::CFindFile find;
if(find.FindFile(GetModulePath(_T("Pallets\\*.apl"))))
{
do
{
if(find.IsDots() || find.IsDirectory())continue;
pallets.Add(find.GetFilePath());
} while(find.FindNextFile());
}
}
DWORD* pRGB = (DWORD*)(m_lpbi+1);
if(options.nBmpPallet==0)MakeBzPallet256(pRGB);
else MakeSafetyPallet256(pRGB);
// MakeRedPallet256(pRGB);
switch(options.nBmpPallet)
{
case 0:
MakeBzPallet256(pRGB);
break;
case 1:
MakeSafetyPallet256(pRGB);
break;
default:
if(options.nBmpPallet>=CUSTOMPALLET && pallets.GetCount()+CUSTOMPALLET > options.nBmpPallet)LoadAplPallet256(pRGB, pallets[options.nBmpPallet-CUSTOMPALLET]);
else {
MakeBzPallet256(pRGB);
options.nBmpPallet=0;
options.nBmpColorWidth = 8;
}
break;
}
// TODO: calculate the total size of this view
int cViewX = options.nBmpWidth * options.nBmpZoom + BMPSPACE*2;
......
......@@ -145,6 +145,7 @@ public:
bAddressTooltip = GetProfileInt(key, _T("BmpAddressTooltip"), TRUE);
bMiniToolbar = GetProfileInt(key, _T("MiniToolbar"), TRUE);
lastPalletName = GetProfileString(key, _T("lastPalletName"));
CheckOptions();
// key.Flush();
......@@ -204,7 +205,7 @@ public:
void CheckOptions()
{
if(nBmpPallet!=0 && nBmpPallet!=1)nBmpPallet = 1;
//if(nBmpPallet!=0 && nBmpPallet!=1)nBmpPallet = 1;
switch(nBmpColorWidth)
{
case 8:
......@@ -365,6 +366,7 @@ public:
WriteFileInt(file, "BmpAddressTooltip", bAddressTooltip);
WriteFileInt(file, "MiniToolbar", bMiniToolbar);
WriteFileString(file, "lastPalletName", lastPalletName);
file.Flush();
......@@ -441,6 +443,7 @@ public:
WriteProfileInt(key, _T("BmpAddressTooltip"), bAddressTooltip);
WriteProfileInt(key, _T("MiniToolbar"), bMiniToolbar);
WriteProfileString(key, _T("lastPalletName"), lastPalletName);
key.Flush();
}
......@@ -496,6 +499,8 @@ public:
BOOL bMiniToolbar;
CString lastPalletName;
public:
CBZOptions() : m_bModified(FALSE), bPortableMode(FALSE) { }
......
struct BITMAPFILEHEADER
{
WORD bfType;
dword bfSize;
word bfReserved1;
word bfReserved2;
dword bfOffBits;
} bmp;
struct RIFF {
DWORD ckid;
dword cksize;
DWORD fccType;
} ani , avi , mpg;
struct BITMAPINFOHEADER
{
dword biSize;
long biWidth;
long biHeight;
word biPlanes;
word biBitCount
dword biCompression;
dword biSizeImage;
long biXPelsPerMeter;
long biYPelsPerMeter;
dword biClrUsed;
dword biClrImportant;
} bmp;
struct ANIHEADER {
dword cbSizeof;
dword cFrames;
dword cSteps;
dword cx , cy;
dword cBitCount , cPlanes;
dword jifRate;
dword fl;
} ani;
struct CURSORDIR {
word cdReserved;
word cdType;
word cdCount;
} cur , ani;
struct CURSORDIRENTRY {
byte bWidth;
byte bHeight;
byte bColorCount;
byte bReserved;
word wXHotspot;
word wYHotspot;
dword dwBytesInRes;
DWORD dwImageOffset;
} cur , ani;
struct ICONDIR {
word idReserved;
word idType;
word idCount;
} ico;
struct ICONDIRENTRY {
byte bWidth;
byte bHeight;
byte bColorCount;
byte bReserved;
word wPlanes;
word wBitCount;
dword dwBytesInRes;
dword dwImageOffset;
byte bWidth;
byte bHeight;
byte bColorCount;
byte bReserved;
word wPlanes;
word wBitCount;
dword dwBytesInRes;
DWORD dwImageOffset;
} ico;
struct CURSORDIRENTRY {
byte bWidth;
byte bHeight;
byte bColorCount;
byte bReserved;
word wXHotspot;
word wYHotspot;
dword dwBytesInRes;
dword dwImageOffset;
} cur;
struct BITMAPFILEHEADER {
WORD bfType;
dword bfSize;
word bfReserved1;
word bfReserved2;
dword bfOffBits;
} bmp;
struct ANIHEADER {
dword cbSizeof;
dword cFrames;
dword cSteps;
dword cx , cy;
dword cBitCount , cPlanes;
dword jifRate;
dword fl;
} ani;
struct BITMAPINFOHEADER {
dword biSize;
long biWidth;
long biHeight;
word biPlanes;
word biBitCount;
dword biCompression;
dword biSizeImage;
long biXPelsPerMeter;
long biYPelsPerMeter;
dword biClrUsed;
dword biClrImportant;
} bmp , ico , cur;
struct SWF_HEADER {
byte Signature [3];
byte Version;
long FileLength;
DWORD FrameWidth;
DWORD FrameHeight;
short FrameRate;
short FrameCount;
} swf;
struct ZIP_HEADER {
BYTE signature [4];
WORD version;
WORD flags;
word compression;
WORD dos_time;
WORD dos_date;
DWORD crc32;
dword compressed_size;
dword uncompressed_size;
word filename_length;
word extra_field_length;
} zip;
struct METAFILEHEADER {
DWORD key;
short handle;
short bbox_x1;
short bbox_y1;
short bbox_x2;
short bbox_y2;
short inch;
dword reserved;
WORD checksum;
} wmf;
struct METAHEADER {
word mtType;
word mtHeaderSize;
WORD mtVersion;
dword mtSize;
word mtNoObjects;
dword mtMaxRecord;
word mtNoParameters;
} wmf;
struct FONTINFO {
WORD dfType;
short dfPoints;
short dfVertRes;
short dfHorizRes;
short dfAscent;
short dfInternalLeading;
short dfExternalLeading;
byte dfItalic;
byte dfUnderline;
byte dfStrikeOut;
short dfWeight;
byte dfCharSet;
short dfPixWidth;
short dfPixHeight;
byte dfPitchAndFamily;
short dfAvgWidth;
short dfMaxWidth;
byte dfFirstChar;
byte dfLastChar;
byte dfDefaultChar;
byte dfBreakChar;
short dfWidthbytes;
dword dfDevice;
dword dfFace;
dword dfBitsPointer;
dword dfBitsOffset;
byte dfReserved;
long dfFlags;
short dfAspace;
short dfBspace;
short dfCspace;
long dfReserved;
long dfReserved1 [4];
} fnt;
\ No newline at end of file
struct AZPALLET {
BYTE signature [6];
BYTE version;
WORD count;
DWORD color[1024];
} apl;
This diff is collapsed.
......@@ -30,7 +30,7 @@ typedef struct Scanner
PassData val;
} Scanner;
enum {TYPE_CharSet=0, TYPE_AutoDetect, TYPE_ByteOrder, TYPE_FontName, TYPE_FontStyle, TYPE_FontSize, TYPE_FrameLeft, TYPE_FrameTop, TYPE_CmdShow, TYPE_FrameHeight, TYPE_FrameHeight2, TYPE_FrameWidth2, TYPE_SplitHPos, TYPE_SplitVPos, TYPE_SplitStruct, TYPE_StructView, TYPE_ComboHeight, TYPE_Language, TYPE_DetectMax, TYPE_BarState, TYPE_ReadOnly, TYPE_BmpWidth, TYPE_BmpZoom, TYPE_BmpPallet, TYPE_MaxOnMemory, TYPE_MaxMapSize, TYPE_TagAll, TYPE_SubCursor, TYPE_Colors, TYPE_MemberColumns2, TYPE_PageMargin, TYPE_DumpHeader, TYPE_DumpPage, TYPE_QWordAddr, TYPE_ClearUndoRedoWhenSave, TYPE_SyncScroll, TYPE_Grid, TYPE_BmpColorWidth, TYPE_InspectView, TYPE_AnalyzerView, TYPE_BmpAddressTooltip, TYPE_MiniToolbar};
enum {TYPE_CharSet=0, TYPE_AutoDetect, TYPE_ByteOrder, TYPE_FontName, TYPE_FontStyle, TYPE_FontSize, TYPE_FrameLeft, TYPE_FrameTop, TYPE_CmdShow, TYPE_FrameHeight, TYPE_FrameHeight2, TYPE_FrameWidth2, TYPE_SplitHPos, TYPE_SplitVPos, TYPE_SplitStruct, TYPE_StructView, TYPE_ComboHeight, TYPE_Language, TYPE_DetectMax, TYPE_BarState, TYPE_ReadOnly, TYPE_BmpWidth, TYPE_BmpZoom, TYPE_BmpPallet, TYPE_MaxOnMemory, TYPE_MaxMapSize, TYPE_TagAll, TYPE_SubCursor, TYPE_Colors, TYPE_MemberColumns2, TYPE_PageMargin, TYPE_DumpHeader, TYPE_DumpPage, TYPE_QWordAddr, TYPE_ClearUndoRedoWhenSave, TYPE_SyncScroll, TYPE_Grid, TYPE_BmpColorWidth, TYPE_InspectView, TYPE_AnalyzerView, TYPE_BmpAddressTooltip, TYPE_MiniToolbar, TYPE_lastPalletName};
void SetIntOption(uint type, int val)
{
......@@ -82,6 +82,7 @@ void SetStrOption(uint type, CString *pVal)
{
case TYPE_FontName: options.sFontName = *pVal; break;
case TYPE_DumpHeader: options.sDumpHeader = *pVal; break;
case TYPE_lastPalletName: options.lastPalletName = *pVal; break;
}
}
......@@ -222,6 +223,7 @@ RGBA = [#] (H {8});
"AnalyzerView" { RETT(INTTYPE, TYPE_AnalyzerView); }
"BmpAddressTooltip" { RETT(INTTYPE, TYPE_BmpAddressTooltip); }
"MiniToolbar" { RETT(INTTYPE, TYPE_MiniToolbar); }
"lastPalletName" { RETT(STRTYPE, TYPE_lastPalletName); }
[+-]? [ \t]* (D+) { uchar *start = s->tok;
......
......@@ -136,6 +136,8 @@
#define ID_BMPVIEW_PALETTE_SAFETY 32855
#define ID_VIEW_ANALYZER 32858
#define ID_BMP 32859
#define ID_BMPVIEW_CUSTOMPALETTE_START 35000
#define ID_BMPVIEW_CUSTOMPALETTE_END 35100
#define ID_INDICATOR_INFO 0xE710
#define ID_INDICATOR_SIZE 0xE711
#define ID_INDICATOR_CHAR 0xE712
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment