Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2007.11.04;
Скачать: [xml.tar.bz2];

Вниз

2 битмапа в 1   Найти похожие ветки 

 
Альберт ©   (2007-04-30 23:37) [0]

есть два bitmap
один из окна (24 bit), второй - 8 bit из файла. работа только через винапи. цель составить 32 bit .


type

  TScr = array [0..1] of Byte;
  PScr = ^TScr;

  Data = record
     SIZE:DWord;
     BIH:^BITMAPINFO;
     DC:HDC;
     HANDLE:HBITMAP;
  end;

function getBitmapColorTableFromWindow(WND:HWND{; bits:PScr}):Data;
var

  WND_RECT:TRECT;
  hBmp       : hBitmap;
  DeskDC     : hDC;
  DC         : hDC;
  BFH        : BITMAPFILEHEADER;
  BIH        : tagBITMAPINFO;
  ScrX, ScrY : Integer;
  ScrSize    : Cardinal;
  Bits       : PScr;
  RETURN_DATA: Data;
begin
  Windows.GetWindowRect(WND,WND_RECT);
  SCRX     := (WND_RECT.Right - WND_RECT.Left);
  SCRY     := (WND_RECT.Bottom - WND_RECT.Top);
  ScrSize  := ScrX * ScrY * 3;
  GetMem(Bits, ScrSize);
  DeskDC   := GetDC(WND);
  hBmp     := CreateCompatibleBitmap(DeskDC, ScrX, ScrY);
  DC       := CreateCompatibleDC(DeskDC);

  SelectObject(DC, hbmp);
  BitBlt(DC, 0, 0, SCRX, SCRY, DeskDC, 0, 0, SrcCopy);

  with BFH do
  begin
    bfType      := $4D42;
    bfSize      := SCRX * SCRY * 3 + SizeOf(BFH) + SizeOf(BIH);
    bfReserved1 := 0;
    bfReserved2 := 0;
    bfOffBits   := SizeOf(BFH) + SizeOf(BIH);
  end;

  with BIH.bmiHeader do

  begin
   biSize         := sizeof(BIH);
   biWidth        := SCRX;
   biHeight       := SCRY;
   biPlanes       := 1;
   biBitCount     := 24;
   biCompression  := BI_RGB;
   biSizeImage    := ScrSize;
   biClrImportant := 0;
  end;

  GetDiBits(DC, hbmp, 0, SCRY, Bits, BIH, DIB_RGB_COLORS);
//   DeleteObject(hbmp);

  GetMEM(RETURN_DATA.BIH, SizeOf(BIH));
  RETURN_DATA.BIH^:=BIH;
  RETURN_DATA.SIZE := ScrSize;
  RETURN_DATA.DC:=DC;
  RETURN_DATA.HANDLE:=hbmp;
  RESULT:=RETURN_DATA;
end;

function getBitmapColorTableFromFile(pszFilename:PCHAR; bits: PSCR):Data;
var
  F   : FILE;
  BFH : BITMAPFILEHEADER;
//   BIH : ^BITMAPINFO;
  COLOR_TABLE_SIZE: DWORD;
//   bits: PSCR;
  i:integer;
begin

  assignfile(f,pszFilename);
  reset(F,1);
  //messageBox(asd,pchar(inttostr(COLOR_TABLE_SIZE)),pchar(inttostr((filepos(F)))),0 );
  blockread(f, BFH, SizeOf(BFH));
  GetMem(RESULT.BIH, BFH.bfOffBits - 14);
  blockread(f,RESULT.BIH^, {filesize(f) - 14 - COLOR_TABLE_SIZE} BFH.bfOffBits - 14 );
  COLOR_TABLE_SIZE :=  RESULT.BIH^.bmiHeader.biWidth * RESULT.BIH^.bmiHeader.biHeight * RESULT.BIH^.bmiHeader.biBitCount shr 3;

 // messageBox(asd,pchar(inttostr(COLOR_TABLE_SIZE)),pchar(inttostr((filepos(F)))),0 );

  GetMem(bits, COLOR_TABLE_SIZE);
  blockread(f, bits^, COLOR_TABLE_SIZE, i);
//   messageBox(asd,pchar(inttostr(COLOR_TABLE_SIZE)),pchar(inttostr((i))),0);
  closefile(f);

  RESULT.DC         := GetDC(0);
  RESULT.HANDLE     := CreateCompatibleBitmap(RESULT.DC , RESULT.BIH^.bmiHeader.biWidth, RESULT.BIH^.bmiHeader.biHeight);
  RESULT.DC         := CreateCompatibleDC(RESULT.DC );

  SetDiBits(RESULT.DC, RESULT.HANDLE, 0, RESULT.BIH^.bmiHeader.biHeight, bits, RESULT.BIH^, DIB_RGB_COLORS);
  SelectObject(RESULT.DC, RESULT.HANDLE);

//   BitBlt(getDC(0),0,0,RESULT.BIH^.bmiHeader.biWidth , RESULT.BIH^.bmiHeader.biHeight,  RESULT.DC,0,0,SRCCOPY);

//   messageBox(asd,pchar(inttostr((34))),"",0);
  RESULT.SIZE := COLOR_TABLE_SIZE;

  // àëüòåðíàòèâà  //  RESULT.HANDLE:=loadimage(0,pszfilename,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
end;

function createBitmap32(W, H:WORD):DATA;
var ScrSize:Cardinal;
begin
 ScrSize  := W * H * 4;

 GETMEM(RESULT.BIH, sizeOf(tagBITMAPINFO));

 with RESULT.BIH^.bmiHeader do

  begin
   biSize         := sizeof(tagBITMAPINFO);
   biWidth        := W;
   biHeight       := H;
   biPlanes       := 1;
   biBitCount     := 32;
   biCompression  := BI_RGB;
   biSizeImage    := ScrSize;
   biClrImportant := 0;
  end;
  RESULT.DC := GetDC(0);
  RESULT.HANDLE     := CreateCompatibleBitmap(RESULT.DC, W, H);
  RESULT.DC         := CreateCompatibleDC(RESULT.DC);

  SelectObject(RESULT.DC,RESULT.HANDLE);

end;



 
Альберт ©   (2007-04-30 23:38) [1]

а вот и мой тупой рабочий код с


function joinBitmaps(WND:HWND; pszFilename:PCHAR ):HBITMAP;
type

  TScr = array [0..1] of Byte;
  PScr = ^TScr;

var

  DeskDC     : hDC;
  DC         : hDC;
  BIH        : tagBITMAPINFO;
  Bits8,Bits24,Bits32 : Pointer;//PScr;

  WND_RECT:TRECT;

  hBmp8, hBmp24,hBmp32:HBITMAP;

 xx, yy: Integer;  // Ñ÷åò÷èêè öèêëîâ
 SrcBase, {MapBase,} DstBase: Pointer; // Óêàçàòåëè íà ñòðîêè ïèêñåëåé

 MapBase:pbyte;

 SrcInc, MapInc, DstInc: Integer; // Ðàçìåðû ñòðîê ïèêñåëåé
 SrcPixel: PRGBTriple; // ïèêñåëü 24-áèòíîé êàðòèíêè
 Alpha: PByte; // ïèêñåëü 8-áèòíîé êàðòèíêè
 DstPixel: PRGBQuad; // ïèêñåëü 32-áèòíîé êàðòèíêè

 DST_DATA, MAP_DATA, SRC_DATA:DATA;
 PreMultiplyTable: array [0..255,0..255] of Byte;

//------------------

begin

  bits24:=nil;
  SRC_DATA:=getBitmapColorTableFromWindow(WND);
  GetMem(bits24, SRC_DATA.BIH^.bmiHeader.biSizeImage);
  GetDiBits(SRC_DATA.DC, SRC_DATA.HANDLE, 0, SRC_DATA.BIH^.bmiHeader.biHeight, bits24, SRC_DATA.BIH^, DIB_RGB_COLORS);
//   BitBlt(GETDC(0),0,0, SRC_DATA.BIH^.bmiHeader.biWidth, SRC_DATA.BIH^.bmiHeader.biHeight,SRC_DATA.DC,0,0,SRCCOPy);

  bits8:=nil;
  MAP_DATA := getBitmapColorTableFromFile(pszfilename, bits8);
  GetMem(bits8, MAP_DATA.BIH^.bmiHeader.biSizeImage);
  GetDiBits(MAP_DATA.DC, MAP_DATA.HANDLE, 0, MAP_DATA.BIH^.bmiHeader.biHeight, bits8, MAP_DATA.BIH^, DIB_RGB_COLORS);

//   BitBlt(GETDC(0),0,0, MAP_DATA.BIH^.bmiHeader.biWidth, MAP_DATA.BIH^.bmiHeader.biHeight,MAP_DATA.DC,0,0,SRCCOPy);

  DST_DATA:=createBitmap32(SRC_DATA.BIH^.bmiHeader.biWidth, SRC_DATA.BIH^.bmiHeader.biHeight);
  hbmp32:=DST_DATA.HANDLE;
  GetMem(bits32, DST_DATA.BIH^.bmiHeader.biSizeImage);

//  alert(inttostr(1 shl 2));  // 4!

  SRCBASE := @bits24;
  MAPBASE := @bits8;
  DSTBASE := @bits32;
{
 SRCINC := SRC_DATA.BIH^.bmiHeader.biWidth * 3;
 MAPINC := MAP_DATA.BIH^.bmiHeader.biWidth;
 DSTINC := SRC_DATA.BIH^.bmiHeader.biWidth * 4;
}
 for yy := 0 to MAP_DATA.BIH^.bmiHeader.biHeight - 1 do
 for xx := 0 to MAP_DATA.BIH^.bmiHeader.biWidth - 1 do
 begin
   alert(inttostr(BYTE(MAPBASE^)));
   MAPBASE:=MAPBASE + 1;
 end;

 {

  for yy := 0 to DST_DATA.BIH^.bmiHeader.biHeight - 1 do begin
   if yy< MAP_DATA.BIH^.bmiHeader.biHeight then
   begin

   end;

  for xx := 0 to DST_DATA.BIH^.bmiHeader.biWidth - 1 do
  begin
//    if xx< MAP_DATA.BIH^.bmiHeader.biWidth then
   begin
       DWORD(DSTBASE^):=DWORD(SRCBASE^);//(BYTE(MAPBASE^) shl 4){ or (DWORD(SRCBASE^))}; {alpha, rgb}
{
       alert(inttostr(DWORD(SRCBASE^)));

       DWORD(DSTBASE ):=DWORD(DSTBASE) + 4;
       DWORD(MAPBASE ):=DWORD(MAPBASE) + 1;
       DWORD(SRCBASE ):=DWORD(SRCBASE) + 3;
   end;

  end;

  end;
  SetDiBits(DST_DATA.DC, hbmp32, 0, SRC_DATA.BIH^.bmiHeader.biHeight, Bits32, DST_DATA.BIH^, DIB_RGB_COLORS);
  BitBlt(GetDC(0),0,0,DST_DATA.BIH^.bmiHeader.biWidth,DST_DATA.BIH^.bmiHeader.biHe ight,DST_DATA.DC,0,0,SRCCOPy);

 {
 for yy := 0 to DST_DATA.BIH^.bmiHeader.biHeight - 1 do begin
   // &#207;&#238;&#235;&#243;&#247;&#224;&#229;&#236; &#239;&#229;&#240;&#226;&#251;&#233; &#239;&#232;&#234;&#241;&#229;&#235;&#252; &#226; &#241;&#242;&#240;&#238;&#234;&#229;
   DWORD(SrcPixel) := DWORD(bits24);
   Alpha := bits8;
   DWORD(DstPixel) := DWORD(bits32);
   // &#207;&#229;&#240;&#229;&#225;&#232;&#240;&#224;&#229;&#236; &#226;&#241;&#229; &#239;&#232;&#234;&#241;&#229;&#235;&#232; &#226; &#241;&#242;&#240;&#238;&#234;&#229;
   for xx := 0 to DST_DATA.BIH^.bmiHeader.biWidth - 1 do begin
     // &#211;&#241;&#242;&#224;&#237;&#224;&#226;&#235;&#232;&#226;&#224;&#229;&#236; &#246;&#226;&#229;&#242;&#238;&#226;&#251;&#229; &#234;&#238;&#236;&#239;&#238;&#237;&#229;&#237;&#242;&#251; 32-&#225;&#232;&#242;&#237;&#238;&#233; &#234;&#224;&#240;&#242;&#232;&#237;&#234;&#232;, &#239;&#238;
     // &#231;&#237;&#224;&#247;&#229;&#237;&#232;&#255;&#236; &#239;&#240;&#229;&#228;&#243;&#236;&#237;&#238;&#230;&#229;&#237;&#237;&#238;&# 233; &#242;&#224;&#225;&#235;&#232;&#246;&#251;.
     DstPixel.rgbRed   := PreMultiplyTable[Byte(Alpha^), SrcPixel.rgbtRed];
     DstPixel.rgbGreen := PreMultiplyTable[Byte(Alpha^), SrcPixel.rgbtGreen];
     DstPixel.rgbBlue  := PreMultiplyTable[Byte(Alpha^), SrcPixel.rgbtBlue];
     DstPixel.rgbReserved := Byte(Alpha^); // &#224;&#235;&#252;&#244;&#224;-&#234;&#224;&#237;&#224;&#235; &#225;&#229;&#231; &#232;&#231;&#236;&#229;&#237;&#229;&#237;&#232;&#233;
     // &#207;&#238;&#235;&#243;&#247;&#224;&#229;&#236; &#241;&#235;&#229;&#228;&#243;&#254;&#249;&#232;&#233; &#239;&#232;&#234;&#241;&#229;&#235; &#226; &#234;&#224;&#240;&#242;&#232;&#237;&#234;&#224;&#245;
     DWORD(SrcPixel) := DWORD(SrcPixel) + SizeOf(TRGBTriple);
     DWORD(DstPixel) := DWORD(DstPixel) + SizeOf(TRGBQuad);
     DWORD(Alpha)    := DWORD(Alpha)    + SizeOf(Byte);
   end;
   // &#207;&#238;&#235;&#243;&#247;&#224;&#229;&#236; &#241;&#235;&#229;&#228;&#243;&#254;&#249;&#243;&#254; &#241;&#242;&#240;&#238;&#234;&#243;
   DWORD(bits24) := DWORD(bits24) + SrcInc;
   DWORD(bits8) := DWORD(bits8) + MapInc;
   DWORD(bits32) := DWORD(bits32) + DstInc;
 end;

   with BIH.bmiHeader do
  begin
   biSize         := sizeof(BIH);
   biWidth        := SRC_DATA.BIH^.bmiHeader.biWidth;
   biHeight       := SRC_DATA.BIH^.bmiHeader.biHeight;
   biPlanes       := 1;
   biBitCount     := 32;
   biCompression  := BI_RGB;
   biSizeImage    := SRC_DATA.BIH^.bmiHeader.biWidth * 4 * SRC_DATA.BIH.bmiHeader.biHeight;
   biClrImportant := 0;
  end;
 //DC:= CreateCompatibleDC(SRC_DATA.DC);
 SetDiBits(DC, hbmp32, 0, SRC_DATA.BIH^.bmiHeader.biHeight, Bits32, BIH, DIB_RGB_COLORS);

 BitBlt(DC,0,0,SRC_DATA.BIH^.bmiHeader.biWidth,SRC_DATA.BIH^.bmiHeader.biHeight,G ETDC(0),0,0,SRCCOPy);
    //}
end;


 
Альберт ©   (2007-05-01 14:15) [2]

короче разобрался с кодом, но рисуется не то что-то


function getBitmapColorTableFromFile;

var
  F   : FILE;
  BFH : BITMAPFILEHEADER;
  COLOR_TABLE_SIZE: DWORD;
  i:integer;
begin

  assignfile(f,pszFilename);
  reset(F,1);
  blockread(f, BFH, SizeOf(BFH));
  GetMem(RESULT.BIH, BFH.bfOffBits - 14);
  blockread(f,RESULT.BIH^, {filesize(f) - 14 - COLOR_TABLE_SIZE} BFH.bfOffBits - 14 );
  COLOR_TABLE_SIZE :=  RESULT.BIH^.bmiHeader.biWidth * RESULT.BIH^.bmiHeader.biHeight * RESULT.BIH^.bmiHeader.biBitCount shr 3;

  GetMem(bits, COLOR_TABLE_SIZE);
  blockread(f, bits^, COLOR_TABLE_SIZE, i);
  closefile(f);

  RESULT.DC         := GetDC(0);
  RESULT.HANDLE     := CreateCompatibleBitmap(RESULT.DC , RESULT.BIH^.bmiHeader.biWidth, RESULT.BIH^.bmiHeader.biHeight);
  RESULT.DC         := CreateCompatibleDC(RESULT.DC );

  SetDiBits(RESULT.DC, RESULT.HANDLE, 0, RESULT.BIH^.bmiHeader.biHeight, bits, RESULT.BIH^, DIB_RGB_COLORS);
  SelectObject(RESULT.DC, RESULT.HANDLE);

  RESULT.SIZE := COLOR_TABLE_SIZE;

  // &#224;&#235;&#252;&#242;&#229;&#240;&#237;&#224;&#242;&#232;&#226;&#224;  //  RESULT.HANDLE:=loadimage(0,pszfilename,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
end;

function getBitmapColorTableFromWindow;
var

  WND_RECT:TRECT;
  hBmp       : hBitmap;
  DeskDC     : hDC;
  DC         : hDC;
  BFH        : BITMAPFILEHEADER;
  BIH        : tagBITMAPINFO;
  ScrX, ScrY : Integer;
  ScrSize    : Cardinal;
  Bits       : PScr;
  RETURN_DATA: Data;
begin
  Windows.GetWindowRect(WND,WND_RECT);
  SCRX     := (WND_RECT.Right - WND_RECT.Left);
  SCRY     := (WND_RECT.Bottom - WND_RECT.Top);
  ScrSize  := ScrX * ScrY * 3;
  GetMem(Bits, ScrSize);
  DeskDC   := GetDC(WND);
  hBmp     := CreateCompatibleBitmap(DeskDC, ScrX, ScrY);
  DC       := CreateCompatibleDC(DeskDC);

  SelectObject(DC, hbmp);
  BitBlt(DC, 0, 0, SCRX, SCRY, DeskDC, 0, 0, SrcCopy);

  with BFH do
  begin
    bfType      := $4D42;
    bfSize      := SCRX * SCRY * 3 + SizeOf(BFH) + SizeOf(BIH);
    bfReserved1 := 0;
    bfReserved2 := 0;
    bfOffBits   := SizeOf(BFH) + SizeOf(BIH);
  end;

  with BIH.bmiHeader do

  begin
   biSize         := sizeof(BIH);
   biWidth        := SCRX;
   biHeight       := SCRY;
   biPlanes       := 1;
   biBitCount     := 24;
   biCompression  := BI_RGB;
   biSizeImage    := ScrSize;
   biClrImportant := 0;
  end;

  GetDiBits(DC, hbmp, 0, SCRY, Bits, BIH, DIB_RGB_COLORS);
//   DeleteObject(hbmp);

  GetMEM(RETURN_DATA.BIH, SizeOf(BIH));
  RETURN_DATA.BIH^:=BIH;
  RETURN_DATA.SIZE := ScrSize;
  RETURN_DATA.DC:=DC;
  RETURN_DATA.HANDLE:=hbmp;
  RESULT:=RETURN_DATA;
end;

function createBitmap32(W, H:WORD):DATA;
var ScrSize:Cardinal;
begin
 ScrSize  := W * H * 4;

 GETMEM(RESULT.BIH, sizeOf(tagBITMAPINFO));

 with RESULT.BIH^.bmiHeader do

  begin
   biSize         := sizeof(tagBITMAPINFO);
   biWidth        := W;
   biHeight       := H;
   biPlanes       := 1;
   biBitCount     := 32;
   biCompression  := BI_RGB;
   biSizeImage    := ScrSize;
   biClrImportant := 0;
  end;
  RESULT.DC := GetDC(0);
  RESULT.HANDLE     := CreateCompatibleBitmap(RESULT.DC, W, H);
  RESULT.DC         := CreateCompatibleDC(RESULT.DC);

  SelectObject(RESULT.DC,RESULT.HANDLE);

end;

function joinBitmaps;

var
//   Bits8,Bits24,Bits32 : Pointer;//PScr;
  Bits8,Bits24,Bits32 : PScr;
 xx, yy: Integer;  // &#209;&#247;&#229;&#242;&#247;&#232;&#234;&#232; &#246;&#232;&#234;&#235;&#238;&#226;
 SrcBase, MapBase, DstBase: Pointer; // &#211;&#234;&#224;&#231;&#224;&#242;&#229;&#235;&#232; &#237;&#224; &#241;&#242;&#240;&#238;&#234;&#232; &#239;&#232;&#234;&#241;&#229;&#235;&#229;&#233;

 SrcInc: Integer; // &#208;&#224;&#231;&#236;&#229;&#240;&#251; &#241;&#242;&#240;&#238;&#234; &#239;&#232;&#234;&#241;&#229;&#235;&#229;&#233;
 DST_DATA, MAP_DATA, SRC_DATA:DATA;
//------------------

begin

//   bits24:=nil;
  SRC_DATA:=getBitmapColorTableFromWindow(WND);
  GetMem(bits24, SRC_DATA.BIH^.bmiHeader.biSizeImage);
  GetDiBits(SRC_DATA.DC, SRC_DATA.HANDLE, 0, SRC_DATA.BIH^.bmiHeader.biHeight, bits24, SRC_DATA.BIH^, DIB_RGB_COLORS);
//   BitBlt(GETDC(0),0,0, SRC_DATA.BIH^.bmiHeader.biWidth, SRC_DATA.BIH^.bmiHeader.biHeight,SRC_DATA.DC,0,0,SRCCOPy);

  bits8:=nil;
  MAP_DATA := getBitmapColorTableFromFile(pszfilename, bits8);
  GetMem(bits8, MAP_DATA.BIH^.bmiHeader.biSizeImage);
  GetDiBits(MAP_DATA.DC, MAP_DATA.HANDLE, 0, MAP_DATA.BIH^.bmiHeader.biHeight, bits8, MAP_DATA.BIH^, DIB_RGB_COLORS);
//   BitBlt(GETDC(0),0,0, MAP_DATA.BIH^.bmiHeader.biWidth, MAP_DATA.BIH^.bmiHeader.biHeight,MAP_DATA.DC,0,0,SRCCOPy);

  DST_DATA:=createBitmap32(MAP_DATA.BIH^.bmiHeader.biWidth, MAP_DATA.BIH^.bmiHeader.biHeight);
  GetMem(bits32, DST_DATA.BIH^.bmiHeader.biSizeImage);

//  alert(inttostr(1 shl 2));  // 4!

  SRCBASE := bits24;
  MAPBASE := bits8;
  DSTBASE := bits32;

 SRCINC := SRC_DATA.BIH^.bmiHeader.biWidth * 3;

 for yy := 0 to MAP_DATA.BIH^.bmiHeader.biHeight - 1 do
begin

 for xx := 0 to MAP_DATA.BIH^.bmiHeader.biWidth - 1 do
 begin
//    alert(inttostr(BYTE(MAPBASE^)));
   DWORD(DSTBASE^):=DWORD(SRCBASE^)  { + BYTE(MAPBASE^) shl 4};
{    alert(inttostr(BYTE (MAPBASE^)));
   alert(inttostr(DWORD(SRCBASE^)));
   alert(inttostr(DWORD(DSTBASE^)));
   alert("ok");
//}
   DWORD(MAPBASE) :=DWORD(MAPBASE) + 1;
   DWORD(SRCBASE) :=DWORD(SRCBASE) + 3;
   DWORD(DSTBASE) :=DWORD(DSTBASE) + 4;

   if xx>=SRC_DATA.BIH^.bmiHeader.biWidth then
   begin
   DWORD(SRCBASE):=DWORD(bits24)+DWORD((yy+1)*SRCINC);
   break;
   end;

 end;
end;
 SetDiBits(MAP_DATA.DC, DST_DATA.HANDLE, 0, SRC_DATA.BIH^.bmiHeader.biHeight, Bits32, SRC_DATA.BIH^, DIB_RGB_COLORS);
 BitBlt(GETDC(0),0,300,DST_DATA.BIH^.bmiHeader.biWidth,DST_DATA.BIH^.bmiHeader.bi Height,DST_DATA.DC,0,0,SRCCOPy);
 result:=0;
end;


 
DVM ©   (2007-05-01 15:53) [3]

А в чем проблема то была?


 
Albert s sotovogo   (2007-05-01 20:18) [4]

ne risuet normalno. teoreti4eski v 32 bitnom risuetsya tolko 24 bitnaya 4ast. a 8 bitnaya primenyaetsya dlya mnogosloinix okon.

predposlednyaya stroka s bitblt


 
Альберт ©   (2007-05-02 20:42) [5]

переписал joinbitmaps

function joinBitmaps;
var
  Bits8,Bits24,Bits32:pointer;
 xx, yy: Integer;  // &#209;&#247;&#229;&#242;&#247;&#232;&#234;&#232; &#246;&#232;&#234;&#235;&#238;&#226;
 SrcBase, MapBase, DstBase: Pointer; // &#211;&#234;&#224;&#231;&#224;&#242;&#229;&#235;&#232; &#237;&#224; &#241;&#242;&#240;&#238;&#234;&#232; &#239;&#232;&#234;&#241;&#229;&#235;&#229;&#233;

 SrcInc: Integer; // &#208;&#224;&#231;&#236;&#229;&#240;&#251; &#241;&#242;&#240;&#238;&#234; &#239;&#232;&#234;&#241;&#229;&#235;&#229;&#233;
 DST_DATA, MAP_DATA, SRC_DATA:DATA;
//------------------
begin
  SRC_DATA:=getBitmapColorTableFromWindow(WND);
  GetMem(bits24, SRC_DATA.BIH^.bmiHeader.biSizeImage);
  GetDiBits(SRC_DATA.DC, SRC_DATA.HANDLE, 0, SRC_DATA.BIH^.bmiHeader.biHeight, bits24, SRC_DATA.BIH^, DIB_RGB_COLORS);

  bits8:=nil;
  MAP_DATA := getBitmapColorTableFromFile(pszfilename, bits8);
  GetMem(bits8, MAP_DATA.BIH^.bmiHeader.biSizeImage);
  GetDiBits(MAP_DATA.DC, MAP_DATA.HANDLE, 0, MAP_DATA.BIH^.bmiHeader.biHeight, bits8, MAP_DATA.BIH^, DIB_RGB_COLORS);
//   BitBlt(GETDC(0),0,0, MAP_DATA.BIH^.bmiHeader.biWidth, MAP_DATA.BIH^.bmiHeader.biHeight,MAP_DATA.DC,0,0,SRCCOPy);

  bits32:=nil;
  DST_DATA:=createBitmap32(MAP_DATA.BIH^.bmiHeader.biWidth, MAP_DATA.BIH^.bmiHeader.biHeight, bits32);
  GetMem(bits32, DST_DATA.BIH^.bmiHeader.biSizeImage);
  SetDiBits(DST_DATA.DC, DST_DATA.HANDLE, 0, SRC_DATA.BIH^.bmiHeader.biHeight, Bits32, SRC_DATA.BIH^, DIB_RGB_COLORS);

  SRCBASE := bits24;
  MAPBASE := bits8;
  DSTBASE := bits32;

 SRCINC := SRC_DATA.BIH^.bmiHeader.biWidth * 3;

 for yy := 0 to MAP_DATA.BIH^.bmiHeader.biHeight - 1 do
begin

 for xx := 0 to MAP_DATA.BIH^.bmiHeader.biWidth - 1 do
 begin
   DWORD(SRCBASE^) := DWORD(MAP_DATA.BIH^.bmiColors[BYTE(MAPBASE^)]) ;

   DWORD(MAPBASE) :=DWORD(MAPBASE) + 1;
   DWORD(SRCBASE) :=DWORD(SRCBASE) + 3;
   DWORD(DSTBASE) :=DWORD(DSTBASE) + 4;

   if xx>=SRC_DATA.BIH^.bmiHeader.biWidth then
   begin
   DWORD(SRCBASE):=DWORD(bits24)+DWORD(yy*SRCINC);
   break;
   end;
 end;
end;
//}

//  SetDiBits(MAP_DATA.DC, MAP_DATA.HANDLE, 0, MAP_DATA.BIH^.bmiHeader.biHeight, Bits8, MAP_DATA.BIH^, DIB_RGB_COLORS);
 SetDiBits(SRC_DATA.DC, SRC_DATA.HANDLE, 0, SRC_DATA.BIH^.bmiHeader.biHeight, Bits24, SRC_DATA.BIH^, DIB_RGB_COLORS);

 BitBlt(GETDC(0),0,200,DST_DATA.BIH^.bmiHeader.biWidth,DST_DATA.BIH^.bmiHeader.bi Height,SRC_DATA.DC,0,0,SRCCOPy);
 BitBlt(GETDC(0),0,0,DST_DATA.BIH^.bmiHeader.biWidth,DST_DATA.BIH^.bmiHeader.biHe ight,MAP_DATA.DC,0,0,SRCCOPy);

 result:=DST_DATA.HANDLE;
end;


 
Альберт ©   (2007-05-02 20:44) [6]

проблема в том, что когда переделываю из 8 битного бмп в 24 битный рисунок неправильно отображается, хотя я ссылаюсь на таблицу цветов как указано в документации



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2007.11.04;
Скачать: [xml.tar.bz2];

Наверх




Память: 0.51 MB
Время: 0.048 c
15-1191760798
Andy BitOff
2007-10-07 16:39
2007.11.04
Блин!!! Как бороться?


3-1182878418
Kley
2007-06-26 21:20
2007.11.04
из Excel в Access


2-1192168137
r.o.o.t
2007-10-12 09:48
2007.11.04
Обработка ошибок в потоке


15-1191597227
Kantemir_maslov
2007-10-05 19:13
2007.11.04
TMemo c CheckBox ами


2-1191952011
SveTTT
2007-10-09 21:46
2007.11.04
Коды кнопок





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский