HRESULT CDXVADecoderMpeg2::DecodeFrameInternal (BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop) { HRESULT hr = S_FALSE; int nSurfaceIndex = -1; CComPtr<IMediaSample> pSampleToDeliver; int nFieldType = -1; int nSliceType = -1; bool bIsField = false; int bFrame_repeat_pict = 0; CHECK_HR_FALSE (FFMpeg2DecodeFrame (&m_PictureParams, &m_QMatrixData, m_SliceInfo, &m_nSliceCount, m_pFilter->GetAVCtx(), m_pFilter->GetFrame(), &m_nNextCodecIndex, &nFieldType, &nSliceType, pDataIn, nSize, &bIsField, &bFrame_repeat_pict)); // Wait I frame after a flush if (m_bFlushed && (!m_PictureParams.bPicIntra || (bIsField && m_PictureParams.bSecondField))) { TRACE_MPEG2 ("CDXVADecoderMpeg2::DecodeFrame() : Flush - wait I frame, %ws\n", FrameType(bIsField, m_PictureParams.bSecondField)); return S_FALSE; } CHECK_HR (GetFreeSurfaceIndex (nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop)); if (!bIsField || (bIsField && !m_PictureParams.bSecondField)) { UpdatePictureParams(nSurfaceIndex); } TRACE_MPEG2 ("CDXVADecoderMpeg2::DecodeFrame() : Surf = %d, PictureType = %d, %ws, m_nNextCodecIndex = %d, rtStart = [%I64d]\n", nSurfaceIndex, nSliceType, FrameType(bIsField, m_PictureParams.bSecondField), m_nNextCodecIndex, rtStart); { CHECK_HR (BeginFrame(nSurfaceIndex, pSampleToDeliver)); // Send picture parameters CHECK_HR (AddExecuteBuffer (DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams)); // Add quantization matrix CHECK_HR (AddExecuteBuffer (DXVA2_InverseQuantizationMatrixBufferType, sizeof(m_QMatrixData), &m_QMatrixData)); // Add slice control CHECK_HR (AddExecuteBuffer (DXVA2_SliceControlBufferType, sizeof (DXVA_SliceInfo)*m_nSliceCount, &m_SliceInfo)); // Add bitstream CHECK_HR (AddExecuteBuffer (DXVA2_BitStreamDateBufferType, nSize, pDataIn, &nSize)); // Decode frame CHECK_HR (Execute()); CHECK_HR (EndFrame(nSurfaceIndex)); } bool bAdded = AddToStore (nSurfaceIndex, pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), rtStart, rtStop, bIsField, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, FFGetCodedPicture(m_pFilter->GetAVCtx())); if (bAdded) { hr = DisplayNextFrame(); } m_bFlushed = false; return hr; }
BOOL CHistogramDlg::OnInitDialog() { HWND hActiveWnd; HWND hTags; FRMDATATYPE type; LPIMAGE lpImage = NULL; int icons[HISTOMARKS]; HWND hDlg = GetSafeHwnd(); lpImage = GetImage(); RightPopup( hDlg ); // set channels combo type = FrameType(ImgGetBaseEditFrame(lpImage)); m_wChannel = IDC_DO_ALL; m_MapValues.wChannel = m_wChannel; ChannelsCombo_Setup(IDC_CHANNELS, type); //This NEEDS to be fixed!!! // setup tags hTags = ::GetDlgItem(hDlg, IDC_TAGS); icons[0] = IDC_HISTOTAG1; icons[1] = IDC_HISTOTAG2; Tag_Init(hTags, HISTOMARKS, 255, &icons[0]); Tag_SetMark(hTags, 0, 85, NO); Tag_SetMark(hTags, 1, 170, NO); m_lpHistos[0] = NULL; // setup the actual histogram and controls set_histo_channel(); return CPPMapExDlg::OnInitDialog(); }
void AnimationFrameSubsetWidget::setFrames(AnimationController* pController) { mType = FrameType(); if (pController == NULL) { return; } const std::vector<Animation*>& anim = pController->getAnimations(); if (anim.empty()) { return; } setFrameType(pController->getFrameType()); mpStartSpin->setFrames(pController); mpStartSpin->setEnabled(true); mpStopSpin->setFrames(pController); mpStopSpin->setEnabled(true); const std::vector<AnimationFrame>& frames = mpStartSpin->getFrames(); mpStartSlider->setRange(0, frames.size()-1); mpStartSlider->setEnabled(true); mpStopSlider->setRange(0, frames.size()-1); mpStopSlider->setEnabled(true); }
int SingleAvroFile::add_child_frame(int node, std::string name, int t) { unsigned int index = get_number_of_frames(); access_frame(index).name = name; access_frame(index).type = boost::lexical_cast<std::string>(FrameType(t)); access_frame(node).children.push_back(index); RMF_INTERNAL_CHECK(get_number_of_frames() == index + 1, "No frame added"); return index; }
// Frame_window - окно рамки. LONG Diver_GetPreDefinedButtonsState( HWND Frame_window ) { // Если окна картинки нет - возврат. if( WinWindowFromID( Frame_window, FID_SYSMENU ) == NULLHANDLE ) return NO_ACTION; // Узнаем, как выглядит рамка окна. LONG Frame_type = FrameType( Frame_window ); // Если окно имеет рамку в одну точку - требуется кнопка закрытия. if( Frame_type == FT_POINT ) return CLOSE_ACTION; // Если это окно постоянного размера - требуется кнопка закрытия. if( Frame_type == FT_CONST ) if( PermissionForButtonsDrawing( Frame_window ) ) return CLOSE_ACTION; // Если окно имеет обычную рамку: if( Frame_type == FT_NORMAL ) { // Если это окно справочника - состояние кнопок может быть любым, возврат. if( WindowIsCreatedBy( APP_VIEWDOC, Frame_window ) ) return NO_ACTION; // Если это текстовое окно - надо рисовать все кнопки, возврат. if( IsVIOWindow( Frame_window ) ) return CLOSE_ACTION | MINIMIZE_ACTION | MAXIMIZE_ACTION; // Задаем состояние кнопок. BYTE Draw_all_buttons = 0; // Если это окно WPS - должны быть нарисованы все кнопки. if( IsFolderWindow( Frame_window ) ) Draw_all_buttons = 1; // Так же, если в окне есть меню и его родительское окно - рабочий стол. if( !Draw_all_buttons ) if( WinWindowFromID( Frame_window, FID_MENU ) != NULLHANDLE ) if( WinQueryWindow( Frame_window, QW_PARENT ) == QueryDesktopWindow() ) Draw_all_buttons = 1; // Если в окне должны быть нарисованы все кнопки: if( Draw_all_buttons ) { // Для некоторых окон нужна только кнопка закрытия. if( Painter_OneActionIsAllowed( Frame_window ) ) return CLOSE_ACTION; // Для некоторых окон не нужна кнопка уменьшения. if( !Painter_MinimizeActionIsAllowed( Frame_window ) ) return CLOSE_ACTION | MAXIMIZE_ACTION; // Для остальных окон нужны все три кнопки. return ALL_ACTIONS; } } // Возврат. return NO_ACTION; }
void FloodProc( HWND hWindow, UINT msg, int x, int y, UINT32 Option ) /************************************************************************/ { FRMDATATYPE type; int res; FLOOD_PARMS parms; LPIMAGE lpImage; RECT rArea; switch (msg) { case WM_CREATE: // The first mouse down message if (!IsOnImage(hWindow, x, y)) break; Display2File(hWindow,&x, &y); lpImage = (LPIMAGE)GetImagePtr(hWindow); type = FrameType(ImgGetBaseEditFrame(lpImage)); res = FrameResolution(ImgGetBaseEditFrame(lpImage)); parms.FloodOpacity = Fill.FloodOpacity; parms.FloodMergeMode = Fill.FloodMergeMode; GetActiveColorFromType(type, &parms.Color); parms.iBaseRes = res; parms.x = x; parms.y = y; rArea.left = rArea.right = x; rArea.top = rArea.bottom = y; Measure(lpImage, &rArea, &parms.InColor); parms.FloodRange = Fill.FloodRange; parms.FloodFade = Fill.FloodFade; parms.idFloodColorModel = Fill.idFillColorModel; ProcessCommand(lpImage->lpCmdList, IDS_CMD_FLOOD, &parms); break; case WM_LBUTTONDOWN: break; case WM_LBUTTONUP: break; case WM_MOUSEMOVE: // sent when ToolActive is on break; case WM_LBUTTONDBLCLK: break; case WM_DESTROY: // The cancel operation message Tool.bActive = NO; break; } }
FrameID MultipleAvroFileWriter::add_frame(std::string name, FrameType t) { unsigned int index = get_number_of_frames(); RMF_TRACE("Adding frame " << index << " under " << get_loaded_frame()); set_loaded_frame(FrameID(index)); frame_.name = name; frame_.type = boost::lexical_cast<std::string>(FrameType(t)); if (get_loaded_frame() != FrameID()) { unsigned int findex = get_loaded_frame().get_index(); frame_.parents.push_back(findex); } frames_dirty_ = true; frame_.index = index; return FrameID(index); }
Frame::FrameInfo Frame::GetFrameInfo() const { SpiceInt centerId; SpiceInt clssid; SpiceInt frclss; SpiceBoolean found; CSPICE_ASSERT(frinfo_c(spiceId, ¢erId, &frclss, &clssid, &found)); FrameInfo finfo; finfo.centerId = centerId; finfo.classId = clssid; finfo.frameType = FrameType(frclss); return finfo; }
CToneBalanceDlg::OnInitDialog() { HWND hControl; FRMDATATYPE type; LPIMAGE lpImage = NULL; int i; LONG style; HWND hDlg = GetSafeHwnd(); PreDoModal(); m_lpData = (LPQUARTERSTRUCT)Alloc(sizeof(QUARTERSTRUCT)); if (!m_lpData) return(FALSE); for (i=0;i<3;i++) // setup tag sliders { if (hControl = ::GetDlgItem(hDlg, i+IDC_QUART1)) { style = GetWindowLong(hControl, GWL_EXSTYLE); style |= WS_EX_TRANSPARENT; SetWindowLong(hControl, GWL_EXSTYLE, style); } } lpImage = GetImage(); RightPopup( hDlg ); // set channels combo type = FrameType(ImgGetBaseEditFrame(lpImage)); m_lpData->wChannel = IDC_DO_ALL; m_MapValues.wChannel = m_lpData->wChannel; //this is not a very good solution ChannelsCombo_Setup(IDC_CHANNELS, type); ControlEnable(hDlg, IDC_PREVIEW, !m_bAutoPreview); // remove or add percents SetAllDlgItemsText(hDlg, IDC_PERCENT, m_bPercentages ? (LPSTR)"%":(LPSTR)""); m_lpData->lpHistos[0] = NULL; ResetAllMaps(); // setup each channel with defaults for (i=IDC_DO_ALL; i<=IDC_DO_BLACK;i++) reset_channel(i); // setup the actual histogram and controls set_quarter_channel(m_lpData->wChannel); return CPPMapDlg::OnInitDialog(); }
LPTR FrameToDIB( LPFRAME lpFrame, LPRECT lpRect ) { RECT Rect; // Make sure that this is a valid pointer if (!lpFrame) { return(NULL); } // Validate the image rectangle if (lpRect == NULL) { lpRect = &Rect; Rect.top = 0; Rect.left = 0; Rect.bottom = FrameYSize( lpFrame ) - 1; Rect.right = FrameXSize( lpFrame ) - 1; } // Call the appropriate conversion function switch (FrameType( lpFrame )) { case FDT_LINEART : return(FrameToLineArtDIB( lpFrame, lpRect )); break; case FDT_GRAYSCALE : case FDT_PALETTECOLOR : return(FrameToPaletteDIB( lpFrame, lpRect )); break; case FDT_RGBCOLOR : case FDT_CMYKCOLOR : return(FrameToColorDIB( lpFrame, lpRect )); break; } return(NULL); }
void TintFillProc( HWND hWindow, UINT msg, int x, int y, UINT32 Option ) /************************************************************************/ { LPIMAGE lpImage; FRMDATATYPE type; TINTFILL_PARMS parms; switch (msg) { case WM_CREATE: // The first mouse down message if (!IsOnImage(hWindow, x, y)) break; lpImage = (LPIMAGE)GetImagePtr ( hWindow ); type = FrameType(ImgGetBaseEditFrame(lpImage)); parms.FillOpacity = Fill.FillOpacity; parms.FillMergeMode = Fill.FillMergeMode; GetActiveColorFromType(type, &parms.Color); ProcessCommand(lpImage->lpCmdList, IDS_CMD_TINTFILL, &parms); break; case WM_LBUTTONDOWN: break; case WM_LBUTTONUP: break; case WM_MOUSEMOVE: // sent when ToolActive is on break; case WM_LBUTTONDBLCLK: break; case WM_DESTROY: // The cancel operation message Tool.bActive = NO; break; } }
void AnimationFrameSubsetWidget::setFrames(Animation* pAnimation) { mType = FrameType(); if (pAnimation == NULL) { return; } setFrameType(pAnimation->getFrameType()); mpStartSpin->setFrames(pAnimation); mpStartSpin->setEnabled(true); mpStopSpin->setFrames(pAnimation); mpStopSpin->setEnabled(true); const std::vector<AnimationFrame>& frames = pAnimation->getFrames(); mpStartSlider->setRange(0, frames.size()-1); mpStartSlider->setEnabled(true); mpStopSlider->setRange(0, frames.size()-1); mpStopSlider->setEnabled(true); }
/*-#+func---------------------------------------------------------------- FUNCTION: ax25rec() PURPOSE: Level 1 to Level 2 conversion SYNTAX: AX25_PACKET *ax25rec(AX25_LEVEL1 *p1) DESCRIPTION: Given a pointer to a level 1 packet, converts it to a level 2 packet structure and returns a pointer to the newly allocated level 2 packetstructure. RETURNS: Returns NULL if an error in the structure of the level 1 packet HISTORY: --#-func----------------------------------------------------------------*/ AX25_PACKET *ax25rec(AX25_LEVEL1 *p1) { AX25_PACKET p2; AX25_PACKET *p; BYTE t1,t2; int cr[4]; cr[0] = UNKNOWN; cr[1] = RESPONSE; cr[2] = COMMAND; cr[4] = UNKNOWN; if(p1->len < 15) { /* minimum number of octets is 17! */ RXCRCErr++; /* Increment error counter */ /* wn_printf(w_mon,"*** INVALID LENGTH %d ***\n",p1->len); */ return NULL; } p1buffer.len = p1->len; memcpy(p1buffer.data,p1->data,p1buffer.len); setbufptr(&p1buffer,0L); /* Intialize buffer pointer */ /*----------------------------------- copy destination callsign and ssid ------------------------------------*/ buf2data((unsigned char *)&p2.dest,&p1buffer,MAXCLEN); t1 = pull8(&p1buffer); p2.dest.ssid = t1 & SSIDMASK; /*----------------------------------- copy source callsign and ssid ------------------------------------*/ buf2data((unsigned char *)&p2.source,&p1buffer,MAXCLEN); t2 = pull8(&p1buffer); p2.source.ssid = t2 & SSIDMASK; /*---------------------- command/response bits -----------------------*/ p2.cmdresp = (BYTE) cr[(((t1 & REPEATED) != 0) << 1) + ((t2 & REPEATED) != 0)]; /*------------------------- copy digipeaters, if any --------------------------*/ p2.ndigis = 0; while(p2.ndigis < MAXDIGIS && ((t2 & 1) == 0)) { buf2data((unsigned char *)&p2.digis[p2.ndigis],&p1buffer,MAXCLEN); t2 = pull8(&p1buffer); p2.digis[p2.ndigis].ssid = t2 & SSIDMASK; p2.repeated[p2.ndigis++] = t2 & REPEATED; } if(p2.ndigis == MAXDIGIS) { /* too many digipeaters */ RXCRCErr++; /* Increment error counter */ /* wn_printf(w_mon,"*** TO MANY DIGIPEATERS ***\n"); */ return NULL; } /*----------------- control field -------------------*/ p2.cont = pull8(&p1buffer); switch(FrameType(p2.cont)) { case I : case UI: p2.pid = pull8(&p1buffer); /* protocol ID */ break; default: break; } /*----------------------------------------------------------- allocate record and copy in header and data field, if any. - 2 bytes for CRC checksum field ! -----------------------------------------------------------*/ p2.dlen = p1buffer.cnt - 2; /* length remaining */ if(p2.dlen > 256 || p2.dlen < 0) { RXCRCErr++; /* Increment error counter */ wn_printf(w_mon,"*** <%d> OUT OF RANGE PACKET ***\n",p2.dlen); return NULL; /* out of range packets */ } /*--------------------------------------- Allocate memory for AX25 packet + data ----------------------------------------*/ p = malloc(sizeof(AX25_PACKET) + p2.dlen); if(p == NULL) return NULL; /* out of memory */ /*----- Copy packet header -----*/ memcpy(p, &p2, sizeof(AX25_PACKET)); /*----- Copy packet data -----*/ if(p2.dlen) buf2data(p->data,&p1buffer,p2.dlen); /*----- return pointer to allocated packet -----*/ return p; }
// Frame_window - окно рамки, Target - какое из окон надо перерисовать. VOID Painter_DrawWindowFrame( HWND Frame_window, ULONG Target ) { // Узнаем размер и расположение окна. RECT Frame_rectangle = {0}; SWP Frame_placement = {0}; Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); // Если окно не показано - возврат. if( Frame_rectangle.yTop <= 1 || Frame_rectangle.xRight <= 1 ) return; // Узнаем, как выглядит рамка окна. LONG Frame_type = FrameType( Frame_window ); // Узнаем, выбрано ли окно. BYTE Window_is_active = WindowIsActive( Frame_window ); // Устанавливаем свойство. SetProperty( Frame_window, PRP_ACTIVATED, &Window_is_active ); // Узнаем окно заголовка. HWND TitleBar_window = WinWindowFromID( Frame_window, FID_TITLEBAR ); // Для некоторых окон можно рисовать только заголовок. BYTE Draw_TitleBar_only = 0; if( !Painter_PermissionForCompleteDrawing( Frame_window ) ) { Draw_TitleBar_only = 1; Target = WT_TITLEBAR; } // Рисуем рамку для окна. if( !Draw_TitleBar_only ) { for( INT Step = 0; Step < MAX_FCHECKS; Step ++ ) { if( Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); Painter_DrawFrameRectangle( Frame_window, Frame_type, &Frame_rectangle, &Frame_placement, Window_is_active ); if( Step != MAX_FCHECKS - 1 ) if( !Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) break; } } // Подчеркиваем объем меню окна. if( Painter.Settings.Draw_menus ) if( Frame_type != FT_FLAT ) if( Target & WT_UNKNOWN || Target & WT_MENU ) { HWND Menu_window = WinWindowFromID( Frame_window, FID_MENU ); if( Menu_window != NULLHANDLE ) { for( INT Step = 0; Step < MAX_FCHECKS; Step ++ ) { if( Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); Painter_DrawWindowMenu( Menu_window, Frame_window, &Frame_rectangle, &Frame_placement ); if( Step != MAX_FCHECKS - 1 ) if( !Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) break; } } } // Узнаем окно обычных кнопок. HWND MinMax_window = WinWindowFromID( Frame_window, FID_MINMAX ); // Если окно плоское: if( Frame_type == FT_FLAT ) { // Если в нем есть окно обычных кнопок - скрываем его. if( Painter.Settings.Draw_buttons ) if( MinMax_window != NULLHANDLE ) WinShowWindow( MinMax_window, 0 ); // Возврат. return; } // А если это не плоское окно: else { // Если свойства окна неизвестны и могут быть определены в будущем - возврат. if( !PropertiesForDrawingAreDetected( Frame_window ) ) if( WinWindowFromID( Frame_window, FID_SYSMENU ) != NULLHANDLE ) return; } // Узнаем окно картинки. HWND SysMenu_window = WinWindowFromID( Frame_window, FID_SYSMENU ); // Узнаем высоту заголовка и картинки. INT TitleBar_height = 0; if( TitleBar_window != NULLHANDLE ) { RECT Rectangle = {0}; WinQueryWindowRect( TitleBar_window, &Rectangle ); TitleBar_height = Rectangle.yTop - 1; } else { TitleBar_height = WinQuerySysValue( QueryDesktopWindow(), SV_CYMINMAXBUTTON ) - 1; } // Окна заголовка и картинки должны быть расположены на одной линии. // Если это не так - окно надо обновить и ничего не рисовать в нем. if( SysMenu_window != NULLHANDLE ) if( TitleBar_window != NULLHANDLE ) if( WinIsWindowVisible( SysMenu_window ) ) { // Узнаем ширину рамки окна. INT Frame_width = 0; FindProperty( Frame_window, PRP_BORDER, &Frame_width ); if( !Frame_width ) Frame_width = FrameWidth( Frame_window ); // Узнаем расположение окна картинки. SWP SysMenu_placement = {0}; WinQueryWindowPos( SysMenu_window, &SysMenu_placement ); // Если оно расположено на своем месте: INT Y_middle_line = Frame_rectangle.yTop - Frame_width - TitleBar_height / 2; if( SysMenu_placement.y < Y_middle_line ) if( SysMenu_placement.y + SysMenu_placement.cy > Y_middle_line ) { // Узнаем расположение окна заголовка. SWP TitleBar_placement = {0}; WinQueryWindowPos( TitleBar_window, &TitleBar_placement ); // Если заголовок расположен не на своем месте: if( TitleBar_placement.y > Y_middle_line || TitleBar_placement.y + TitleBar_placement.cy < Y_middle_line ) { // Обновляем окно. UpdateWindow( Frame_window ); // Возврат. return; } } } // Узнаем, можно ли рисовать для окна новые кнопки. BYTE Draw_new_buttons = 0; if( Painter.Settings.Draw_buttons ) { // Узнаем, было ли определено состояние кнопок. BYTE Actions_are_detected = 0; FindProperty( Frame_window, PRP_ACTIONS, &Actions_are_detected ); // Если оно известно - кнопки можно рисовать. if( Actions_are_detected ) Draw_new_buttons = Painter_PermissionForButtonsDrawing( Frame_window ); } // Кнопки уменьшения и увеличения окна надо скрыть и сжать в "|". Кроме того, рамка // может содержать несколько кнопок слева и справа от заголовка, их надо передвинуть. BYTE Advanced_controls = 0; // Если надо рисовать рамку или заголовок: if( Target & WT_UNKNOWN || Target & WT_BORDER || Target & WT_TITLEBAR ) { // Передвигаем окна в заголовке и задаем подходящие цвета. if( TitleBar_window != NULLHANDLE || MinMax_window != NULLHANDLE ) if( Painter_PermissionForCompleteDrawing( Frame_window ) ) Advanced_controls = Painter_PrepareWindowControls( Frame_window, Frame_type, &Frame_rectangle, &Frame_placement, TitleBar_window, SysMenu_window, MinMax_window ); // Если справа от заголовка были найдены дополнительные окна - запоминаем это. if( Advanced_controls ) SetProperty( Frame_window, PRP_CONTROLS, &Advanced_controls ); } // Рисуем новые кнопки в правом верхнем углу окна. if( Draw_new_buttons ) if( Target & WT_UNKNOWN || Target & WT_BORDER ) if( TitleBar_window != NULLHANDLE ) { for( INT Step = 0; Step < MAX_FCHECKS; Step ++ ) { if( Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); Painter_DrawButtons( Frame_window, Frame_type, &Frame_rectangle, &Frame_placement, TitleBar_window ); if( Step != MAX_FCHECKS - 1 ) if( !Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) break; } } // Рисуем картинку в левом верхнем углу окна. if( Painter.Settings.Draw_system_menus ) if( Target & WT_UNKNOWN || Target & WT_SYSMENU ) if( SysMenu_window != NULLHANDLE ) { // Рисуем картинку. HPOINTER Icon = NULLHANDLE; FindProperty( Frame_window, PRP_ICON, &Icon ); for( INT Step = 0; Step < MAX_FCHECKS; Step ++ ) { if( Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); Painter_DrawSystemMenu( SysMenu_window, Frame_window, &Frame_rectangle, &Frame_placement, Icon, Frame_type, 0 ); if( Step != MAX_FCHECKS - 1 ) if( !Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) break; } // Если окно картинки закрывает рамку - перерисовываем ее. if( Frame_rectangle.xRight + 1 < TitleBar_height * 2 ) { for( INT Step = 0; Step < MAX_FCHECKS; Step ++ ) { if( Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); Painter_DrawFrameRectangle( Frame_window, Frame_type, &Frame_rectangle, &Frame_placement, Window_is_active ); if( Step != MAX_FCHECKS - 1 ) if( !Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) break; } } } // Рисуем заголовок окна. if( Painter.Settings.Draw_titles ) if( Target & WT_UNKNOWN || Target & WT_TITLEBAR ) if( TitleBar_window != NULLHANDLE ) { // Рисуем заголовок. Только подчеркивать его объем нельзя - может получиться окно с незакрашенным заголовком и линиями по краям. CHAR Title[ SIZE_OF_TITLE ] = ""; FindProperty( Frame_window, PRP_TITLE, Title ); for( INT Step = 0; Step < MAX_FCHECKS; Step ++ ) { if( Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); Painter_DrawTitleBar( TitleBar_window, Frame_window, Frame_type, &Frame_rectangle, &Frame_placement, Title, Window_is_active, Advanced_controls ); if( Step != MAX_FCHECKS - 1 ) if( !Painter_FrameRectangleIsChanged( Frame_window, &Frame_rectangle, &Frame_placement ) ) break; } } // Возврат. return; }
int TiffWriteFrame( int oFile, LPSTR lpFileName, LPOBJECT lpObject, LPFRAME lpFrame, LPRECT lpRect, int flag, BOOL fCompressed, BOOL bEscapable) { TAG tag; int y, bpl, npix, nlin, ofp; LPLONG lngptr,boffptr; LPWORD shtptr; DWORD byteoffset; WORD i, numtags, photomet, samples; BYTE bpp; LPWORD lpRed, lpGreen, lpBlue; RGBS RGBmap[256]; LPTR lp, lpBuffer, lpOutputPointer, lpImgScanline; FNAME temp; RECT rSave; BOOL compressInit; #ifdef STATIC16 // only in new framelib CFrameTypeConvert FrameTypeConvert; FRMTYPEINFO SrcTypeInfo; FRMTYPEINFO DstTypeInfo; #endif lpBuffer = NULL; lpImgScanline = NULL; if (!lpFrame) return( -1 ); ProgressBegin(1,0); if ((ofp = oFile) < 0) bEscapable = !FileExists(lpFileName); if ((ofp = oFile) < 0 && (ofp = _lcreat(lpFileName,0)) < 0) { Message( IDS_EWRITE, lpFileName ); goto Exit; } if (lpRect) rSave = *lpRect; else { rSave.top = rSave.left = 0; rSave.bottom = FrameYSize(lpFrame)-1; rSave.right = FrameXSize(lpFrame)-1; } npix = RectWidth(&rSave); nlin = RectHeight(&rSave); switch(flag) { case IDC_SAVELA : case IDC_SAVESP : bpp = 1; bpl = ((npix + 7) / 8); numtags = 11; photomet = 1; samples = 1; break; case IDC_SAVECT : bpp = 8; bpl = npix; numtags = 11; photomet = 1; samples = 1; break; case IDC_SAVE4BITCOLOR : case IDC_SAVE8BITCOLOR : bpp = 8; bpl = npix; numtags = 12; photomet = 3; samples = 1; break; case IDC_SAVE24BITCOLOR : bpp = 24; bpl = npix * 3; numtags = 11; photomet = 2; samples = 3; break; case IDC_SAVE32BITCOLOR : bpp = 32; bpl = npix * 4; numtags = 11; photomet = 5; samples = 4; break; default : goto Exit; break; } compressInit = NO; if ( bpp == 1 ) { AllocLines( &lpBuffer, 1, npix, 2 ); AllocLines( &lpImgScanline, 1, npix, 1 ); } else { AllocLines( &lpBuffer, 1, max(bpl, FrameByteWidth(lpFrame)), 1 ); AllocLines( &lpImgScanline, 1, max(bpl, FrameByteWidth(lpFrame)), 1 ); } if ( !lpBuffer || !lpImgScanline ) { Message( IDS_EMEMALLOC ); _lclose( ofp ); goto Exit; } /* first location where any extra data can be stored */ /* 10 byte header + all tag data (12 bytes each) + 4 bytes (null ifd) */ byteoffset = 10 + (numtags * sizeof(TAG)) + 4; shtptr = (LPWORD)LineBuffer[0]; SetNextWord(&shtptr, 0x4949); /* byte order is LSB,MSB */ SetNextWord(&shtptr, 0x2a); /* tiff version number */ SetNextWord(&shtptr, 8); /* byte offset to first image file directory LSW */ SetNextWord(&shtptr, 0); /* byte offset to first image file directory MSW */ SetNextWord(&shtptr, numtags); /* number of entries in IFD */ tag.tagno = 0xff; /* tag 0xff, subfile type */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = 1; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x100; /* tag 0x100, number of pixels */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = npix; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x101; /* tag 0x101, number of lines */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = nlin; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x102; /* tag 0x102, bits per sample */ tag.type = 3; /* field type is short */ tag.length = samples; /* number of values */ if ( samples == 3 || samples == 4) { tag.value = byteoffset; /* deferred value */ byteoffset += (samples*sizeof(short)); } else tag.value = bpp; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x103; /* tag 0x103, compression */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = (fCompressed ? 5:1); /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x106; /* tag 0x106,photometric inter.(0 = black) */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = photomet; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x111; /* tag 0x111, strip byte offsets */ tag.type = 4; /* field type is long */ tag.length = 1; /* number of values */ tag.value = 0; /* dummy location of the start of image data */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); boffptr = (LPLONG)(shtptr+4); // make boffptr point at tag.value shtptr += 6; tag.tagno = 0x115; /* tag 0x115, samples per pixel*/ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = samples; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x11a; /* tag 0x11a, xresolution */ tag.type = 5; /* field type is rational */ tag.length = 1; /* number of values */ tag.value = byteoffset; /* deferered value */ byteoffset += 8; #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x11b; /* tag 0x11b, yresolution */ tag.type = 5; /* field type is rational */ tag.length = 1; /* number of values */ tag.value = byteoffset; /* deferred value */ byteoffset += 8; #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; tag.tagno = 0x11c; /* tag 0x11c, planar configuration */ tag.type = 3; /* field type is short */ tag.length = 1; /* number of values */ tag.value = 1; /* value */ #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; if ( photomet == 3 ) // Palette color map { tag.tagno = 0x140; /* tag 0x140, colormap */ tag.type = 3; /* field type is short */ tag.length = 3*256; /* number of values */ tag.value = byteoffset; /* value */ byteoffset += (2*3*256); #ifdef _MAC SwapTag(&tag); #endif lmemcpy((LPTR)shtptr,(LPTR)&tag.tagno,12); shtptr += 6; } // Copy the NULL Image File Directory pointer SetNextWord(&shtptr, 0); /* pointer to next IFD */ SetNextWord(&shtptr, 0); // Copy out the Bits Per Sample, if multiple samples if ( samples == 3 ) // The bits per pixel per sample { SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); } // Copy out the Bits Per Sample, if multiple samples if ( samples == 4 ) // The bits per pixel per sample { SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); SetNextWord(&shtptr, 8); } // Copy out the X and Y resolution fields lngptr = (LPLONG)shtptr; #ifdef PPVIDEO SetNextLong(&lngptr, FrameResolution(lpFrame) * 2); /* xreso numerator */ SetNextLong(&lngptr, 2); /* xreso denominator */ SetNextLong(&lngptr, FrameResolution(lpFrame) * 2); /* yreso numerator */ SetNextLong(&lngptr, 2); /* yreso denominator */ #else SetNextLong(&lngptr, FrameResolution(lpFrame)); /* xreso numerator */ SetNextLong(&lngptr, 1); /* xreso denominator */ SetNextLong(&lngptr, FrameResolution(lpFrame)); /* yreso numerator */ SetNextLong(&lngptr, 1); /* yreso denominator */ #endif *boffptr = byteoffset; #ifdef _MAC swapl((LPDWORD)boffptr); #endif // Write out the tags, the bpp, and the resolutions i = (LPTR)lngptr - (LPTR)LineBuffer[0]; if ( _lwrite(ofp, LineBuffer[0], i) != i ) goto BadWrite; // Write the color palette, if necessary if ( photomet == 3 ) // Palette color map { if (!OptimizeBegin(lpObject, lpFrame, RGBmap, 256, NULL /*(LPROC)AstralClockCursor*/, // No Progress report NO, Convert.fOptimize, Convert.fScatter, Convert.fDither, npix)) goto BadWrite; lpRed = (LPWORD)LineBuffer[0]; lpGreen = lpRed + 256; lpBlue = lpGreen + 256; for ( i=0; i<256; i++ ) { *lpRed++ = (WORD)RGBmap[i].red << 8; *lpGreen++ = (WORD)RGBmap[i].green << 8; *lpBlue++ = (WORD)RGBmap[i].blue << 8; } if ( _lwrite(ofp, LineBuffer[0], 2*3*256) != 2*3*256 ) goto BadWrite; } if ( fCompressed ) { if ( CompressLZW( ofp, NULL, 0 ) < 0 ) /* Initialize */ goto BadWrite; compressInit = YES; } switch(bpp) { case 1 : for( y=rSave.top; y<=rSave.bottom; y++ ) { if (AstralClockCursor( y-rSave.top, nlin, bEscapable )) goto Cancelled; if ( lpObject ) { if (!ImgGetLine( NULL, lpObject, rSave.left, y, (rSave.right - rSave.left) + 1, lpImgScanline)) goto BadRead; lp = lpImgScanline; } else { if ( !(lp = FramePointer( lpFrame, rSave.left, y, NO )) ) goto BadRead; } if (FrameDepth(lpFrame) == 0) { if (flag == IDC_SAVESP) diffuse( 0, i, 0, NULL, lp, npix, lpBuffer ); else con2la( lp, npix, lpBuffer ); } else { ConvertData( lp, FrameDepth(lpFrame), npix, lpBuffer+npix, 1 ); if ( flag == IDC_SAVESP ) diffuse( 0, i, 0, NULL, lpBuffer+npix, npix, lpBuffer ); else con2la( lpBuffer+npix, npix, lpBuffer ); } if ( fCompressed ) { if ( CompressLZW( ofp, lpBuffer, bpl ) < 0 ) goto BadWrite; } else { if ( _lwrite( ofp, (LPSTR)lpBuffer, bpl ) != bpl ) goto BadWrite; } } break; case 8 : for( y=rSave.top; y<=rSave.bottom; y++ ) { if (AstralClockCursor( y-rSave.top, nlin, bEscapable )) goto Cancelled; if ( lpObject ) { if (!ImgGetLine( NULL, lpObject, rSave.left, y, (rSave.right - rSave.left) + 1, lpImgScanline)) goto BadRead; lp = lpImgScanline; } else { if ( !(lp = FramePointer( lpFrame, rSave.left, y, NO )) ) goto BadRead; } if (FrameDepth(lpFrame) == 0) { if ( photomet == 3 ) // If we are storing palette color OptimizeData(0, y, npix, lp, lpBuffer, 1 ); else ConvertData( lp, 1, npix, lpBuffer, 1 ); } else { if ( photomet == 3 ) // If we are storing palette color OptimizeData(0, y, npix, lp, lpBuffer, FrameDepth(lpFrame)); else ConvertData( lp, FrameDepth(lpFrame), npix, lpBuffer, 1 ); } if ( fCompressed ) { if ( CompressLZW( ofp, lpBuffer, bpl ) < 0 ) goto BadWrite; } else { if ( _lwrite( ofp, (LPSTR)lpBuffer, bpl ) != bpl ) goto BadWrite; } } break; case 24 : for( y=rSave.top; y<=rSave.bottom; y++ ) { if (AstralClockCursor( y-rSave.top, nlin, bEscapable )) goto Cancelled; if ( lpObject ) { if (!ImgGetLine( NULL, lpObject, rSave.left, y, (rSave.right - rSave.left) + 1, lpImgScanline)) goto BadRead; lp = lpImgScanline; } else { if ( !(lp = FramePointer( lpFrame, rSave.left, y, NO )) ) goto BadRead; } if (FrameType(lpFrame) != FDT_RGBCOLOR) { if (FrameType(lpFrame) != FDT_LINEART) { #ifdef STATIC16 SrcTypeInfo.DataType = FrameType(lpFrame); SrcTypeInfo.ColorMap = NULL; SrcTypeInfo.DataType = FDT_RGBCOLOR; SrcTypeInfo.ColorMap = NULL; FrameTypeConvert.Init(SrcTypeInfo, DstTypeInfo, npix); FrameTypeConvert.ConvertData((LPTR)lp, (LPTR)lpBuffer, y, npix); #else FrameTypeConvert( (LPTR)lp, FrameType(lpFrame), NULL, y, (LPTR)lpBuffer, FDT_RGBCOLOR, NULL, npix); #endif } else { #ifdef STATIC16 SrcTypeInfo.DataType = FDT_GRAYSCALE; SrcTypeInfo.ColorMap = NULL; SrcTypeInfo.DataType = FDT_RGBCOLOR; SrcTypeInfo.ColorMap = NULL; FrameTypeConvert.Init(SrcTypeInfo, DstTypeInfo, npix); FrameTypeConvert.ConvertData((LPTR)lp, (LPTR)lpBuffer, y, npix); #else FrameTypeConvert( (LPTR)lp, FDT_GRAYSCALE, NULL, y, (LPTR)lpBuffer, FDT_RGBCOLOR, NULL, npix); #endif } lpOutputPointer = lpBuffer; } else { lpOutputPointer = lp; } if ( fCompressed ) { if ( CompressLZW( ofp, lpOutputPointer, bpl ) < 0 ) goto BadWrite; } else { if ( _lwrite( ofp, (LPSTR)lpOutputPointer, bpl ) != bpl ) goto BadWrite; } } break; case 32 : for( y=rSave.top; y<=rSave.bottom; y++ ) { if (AstralClockCursor( y-rSave.top, nlin, bEscapable )) goto Cancelled; if ( lpObject ) { if (!ImgGetLine( NULL, lpObject, rSave.left, y, (rSave.right - rSave.left) + 1, lpImgScanline)) goto BadRead; lp = lpImgScanline; } else { if ( !(lp = FramePointer( lpFrame, rSave.left, y, NO )) ) goto BadRead; } if (FrameType(lpFrame) != FDT_CMYKCOLOR) { if (FrameType(lpFrame) != FDT_LINEART) { #ifdef STATIC16 SrcTypeInfo.DataType = FrameType(lpFrame); SrcTypeInfo.ColorMap = NULL; SrcTypeInfo.DataType = FDT_CMYKCOLOR; SrcTypeInfo.ColorMap = NULL; FrameTypeConvert.Init(SrcTypeInfo, DstTypeInfo, npix); FrameTypeConvert.ConvertData((LPTR)lp, (LPTR)lpBuffer, y, npix); #else FrameTypeConvert( (LPTR)lp, FrameType(lpFrame), NULL, y, (LPTR)lpBuffer, FDT_CMYKCOLOR, NULL, npix); #endif } else { #ifdef STATIC16 SrcTypeInfo.DataType = FDT_GRAYSCALE; SrcTypeInfo.ColorMap = NULL; SrcTypeInfo.DataType = FDT_CMYKCOLOR; SrcTypeInfo.ColorMap = NULL; FrameTypeConvert.Init(SrcTypeInfo, DstTypeInfo, npix); FrameTypeConvert.ConvertData((LPTR)lp, (LPTR)lpBuffer, y, npix); #else FrameTypeConvert( (LPTR)lp, FDT_GRAYSCALE, NULL, y, (LPTR)lpBuffer, FDT_CMYKCOLOR, NULL, npix); #endif } lpOutputPointer = lpBuffer; } else { lpOutputPointer = lp; } if ( fCompressed ) { if ( CompressLZW( ofp, lpOutputPointer, bpl ) < 0 ) goto BadWrite; } else { if ( _lwrite( ofp, (LPSTR)lpOutputPointer, bpl ) != bpl ) goto BadWrite; } } break; } if ( compressInit ) if ( CompressLZW( ofp, NULL, 0 ) < 0 ) /* Terminate */ goto BadWrite; compressInit = NO; OptimizeEnd(); if (ofp != oFile) _lclose(ofp); if (lpBuffer) FreeUp( lpBuffer ); if (lpImgScanline) FreeUp( lpImgScanline ); ProgressEnd(); return( 0 ); BadWrite: Message( IDS_EWRITE, lpFileName ); goto BadTiff; BadRead: Message( IDS_EREAD, (LPTR)Control.RamDisk ); Cancelled: BadTiff: if ( compressInit ) if ( CompressLZW( ofp, NULL, 0 ) < 0 ) /* Terminate */ goto BadWrite; compressInit = NO; OptimizeEnd(); if (ofp != oFile) _lclose(ofp); lstrcpy(temp,lpFileName); FileDelete(temp); Exit: if (lpBuffer) FreeUp( lpBuffer ); if (lpImgScanline) FreeUp( lpImgScanline ); ProgressEnd(); return( -1 ); }
void VignetteProc( HWND hWindow, UINT msg, int x, int y, UINT32 Option ) /************************************************************************/ { RECT Rect; BOOL fShift; POINT pt; static int Type, Style; static BOOL fConstrain; static RECT SelectRect; int res; FRMDATATYPE type; LPIMAGE lpImage; STRING szString; GRADIENT_PARMS parms; switch (msg) { case WM_CREATE: // The first mouse down message if (!IsOnImage(hWindow, x, y)) break; ImgGetInfo(GetActiveImage(), NULL, NULL, NULL, &type); if (type == FDT_LINEART) { AstralStrEx( IDC_TOOLNAMESTART+IDC_VIGNETTE, szString, sizeof(szString) ); Message(IDS_NOTWITHLINEART, (LPSTR)szString); break; } AstralUpdateWindow(hWindow); Tool.bActive = YES; // SetMaskingState( x, y ); break; case WM_LBUTTONDOWN: Type = Vignette.Gradient; fConstrain = ( Type == IDC_VIGSQUARE || Type == IDC_VIGCIRCLE ); AstralSetRectEmpty( &SelectRect ); if ( Type == IDC_VIGCIRCLE || Type == IDC_VIGELLIPSE ) Style = SL_ELLIPSE; else if ( Type == IDC_VIGRADIAL || Type == IDC_VIGLINEAR ) Style = SL_LINE; else Style = SL_BOX; pt.x = x; pt.y = y; StartSelection( hWindow, NULL, &SelectRect, Style | SL_SPECIAL, pt, 0L ); break; case WM_LBUTTONUP: Tool.bActive = NO; Rect = SelectRect; // make a copy before it gets ordered EndSelection( hWindow, NULL, &SelectRect, Style, YES ); lpImage = (LPIMAGE)GetImagePtr ( hWindow ); res = FrameResolution(ImgGetBaseEditFrame(lpImage)); type = FrameType(ImgGetBaseEditFrame(lpImage)); parms.VigOpacity = Vignette.VigOpacity; parms.VigMergeMode = Vignette.VigMergeMode; parms.iBaseRes = res; parms.x1 = Rect.left; parms.y1 = Rect.top; parms.x2 = Rect.right; parms.y2 = Rect.bottom; GetActiveColorFromType(type, &parms.StartColor); GetAlternateColorFromType(type, &parms.EndColor); parms.Gradient = Vignette.Gradient; parms.RepeatCount = Vignette.RepeatCount; parms.SoftTransition = Vignette.SoftTransition; parms.Midpoint = Vignette.Midpoint; parms.VigColorModel = Vignette.VigColorModel; ProcessCommand(lpImage->lpCmdList, IDS_CMD_GRADIENT, &parms); break; case WM_MOUSEMOVE: // sent when ToolActive is on fShift = SHIFT; pt.x = x; pt.y = y; UpdateSelection( hWindow, NULL, &SelectRect, Style, pt, fConstrain^CONSTRAINASPECT, 1L, 1L, MOVEKEY||Window.fRButtonDown, FROMCENTER); break; case WM_LBUTTONDBLCLK: break; case WM_DESTROY: // The cancel operation message if (!Tool.bActive) break; Tool.bActive = NO; EndSelection( hWindow, NULL, &SelectRect, Style, YES ); break; } }
/*-#+func---------------------------------------------------------------- FUNCTION: DumpAX25hdr() PURPOSE: Given a pointer to a Level 2 packet structure, creates a human readable level 2 header and info field in ptext. SYNTAX: char *DumpAX25hdr(struct ax25_packet *p) DESCRIPTION: struct ax25_packet *p = pointer to AX25 packet RETURNS: pointer to local static string with header dump HISTORY: 940311 V0.1 - Initial version --#-func----------------------------------------------------------------*/ char *DumpAX25hdr(struct ax25_packet *p) { int i; int showinfo; /* flag for fields with info */ int type; /* frame type */ char t[20]; /* temp space */ static char dtext[1024]; /* Space to dump text to */ dtext[0] = '\0'; /* 'Clear' dumped text array */ /*-------------------------- print the to/from address ---------------------------*/ strcat(dtext,GetAX25Addr(&p->source)); strcat(dtext,">"); strcat(dtext,GetAX25Addr(&p->dest)); /*------------------- print digipeaters --------------------*/ if(p->ndigis) { strcat(dtext," [via "); for(i=0; i<p->ndigis; i++) { strcat(dtext,GetAX25Addr(p->digis + i)); if(p->repeated[i]) strcat(dtext,"*"); if(i != (p->ndigis - 1)) strcat(dtext,","); } strcat(dtext,"]"); } /*------------------------------- decode and show control byte ------------------------------*/ strcat(dtext," <"); showinfo = FALSE; switch(type = FrameType(p->cont)) { case I: strcat(dtext,"I"); showinfo = TRUE; break; case RR: strcat(dtext,"RR"); break; case RNR: strcat(dtext,"RNR"); break; case REJ: strcat(dtext,"REJ"); break; case SABM: strcat(dtext,"SABM"); break; case DISC: strcat(dtext,"DISC"); break; /* DISConnect */ case DM: strcat(dtext,"DM"); break; /* Disconnect Mode */ case UA: strcat(dtext,"UA"); break; case FRMR: strcat(dtext,"FRMR"); break; case UI: strcat(dtext,"UI"); showinfo = TRUE; break; } /*------------------------ show the protocol ID ------------------------*/ if(showinfo) { switch(p->pid) { case PID_X25: /* CCITT X.25 PLP */ strcat(dtext," (X.25 PLP)"); break; case PID_SEGMENT: /* Segmentation fragment */ strcat(dtext," (Segment)"); break; case PID_TEXNET: /* TEXNET datagram protocol */ strcat(dtext," (TEXNET)"); break; case PID_LQ: /* Link quality protocol */ strcat(dtext," Link Quality)"); break; case PID_APPLETALK: /* Appletalk */ strcat(dtext," (APPLETALK)"); break; case PID_APPLEARP: /* Appletalk ARP */ strcat(dtext," (APPLEARP)"); break; case PID_IP: /* ARPA Internet Protocol */ strcat(dtext," (IP)"); break; case PID_ARP: /* ARPA Address Resolution Protocol */ strcat(dtext," (ARP)"); break; case PID_RARP: /* ARPA Reverse Address Resolution Protocol */ strcat(dtext," (RARP)"); break; case PID_NETROM: /* NET/ROM */ strcat(dtext," (NET/ROM)"); break; case PID_NO_L3: /* No level 3 protocol */ strcat(dtext," (Text)"); break; default: sprintf(t," (PID=0x%X)",p->pid); strcat(dtext,t); break; } } /*---------------------- show poll/final bit -----------------------*/ if(p->cont & PF) { switch(p->cmdresp) { case COMMAND: strcat(dtext," (P)"); break; /* cmd, poll */ case RESPONSE: strcat(dtext," (F)"); break; /* resp, final */ case UNKNOWN: strcat(dtext," (P/F)"); break; } } /*----------------------- show sequence numbers ------------------------*/ if((type & 3) != U) { sprintf(t," R%d",(p->cont >> 5) & 7); strcat(dtext,t); }
void grabber( LPSTR lpExtName, int port, HINSTANCE hInstance, HWND hWindow ) { HWND hWnd; /* special conditions: hand scan interface -- with hand scanners the dialog box has a scan frame which gets filled with image data. the dialog box must remain up during reads, so we use the exported frame_open, cacheptr, and frame_close to create the frame instead of device reads. Devopen just returns devcaps, devstart does everything else. special willow gs -- the gs board has 4 different buffers, which contain the following: 0-even pix/even lines, 1-odd pix/even lines, 2-even pix/odd lines, 3-odd pix/odd lines. each call to devread will layer the data so that the buffers will be combined correctly. Device Requirements Byte Decoding: XXXXXXX1b = need to take over display XXXXXXX0b = no need to take over display XXXXXX1Xb = special willow gs read XXXXXX0Xb = no special read XXXX00XXb = image depth, special case palette color 8-bit XXXX01XXb = depth == 1 XXXX10XXb = depth == 2 XXXX11XXb = depth == 3 X1XXXXXXb = special hand scan i/f X0XXXXXXb = standard grab i/f XX1XXXXXb = don't free DLL after exit XX0XXXXXb = free DLL after exit 1XXXXXXXb = putting data from cache to external device 0XXXXXXXb = putting data from external device into cache */ BYTE devreq; // device requirements LPFRAME lpFrame, lpOldFrame; BYTE depth; int lncnt,Datatype; HMODULE hDLL; LPIMAGE lpImage; if ( !(hDLL = (HMODULE)LoadGrabberLibrary(lpExtName)) ) { Message( IDS_EBADDRIVER, NULL ); return; } if ( !(lpImage = GetActiveImage())) lpFrame = NULL; else lpFrame = ImgGetBaseEditFrame(lpImage); lpfnDevName = (DEVNAMEPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(301)); lpfnDevOpen = (DEVOPENPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(302)); lpfnDevCall = (DEVCALLPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(303)); lpfnDevClose = (DEVCLOSEPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(304)); lpfnAcquireProc = (DLGPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(305)); /* get device's intentions -- is this a put to or read from cache */ DevInfo.hInst = hInstance; /* set the data structures */ DevInfo.hPw = hWindow; DevInfo.bFile_is_open = ( lpFrame != NULL ); if(DevInfo.bFile_is_open) { DevInfo.bImg_type = (lpImage->DataType==IDC_SAVECT ? TRUE : FALSE); /* pass the current filename */ lstrcpy(DevInfo.cfname, lpImage->CurFile); } if(!DevOpen(&DevInfo)) { DevCall(DEV_MSG, (LPTR)&DevMsg); /* if MsgNo == 0, then user cancelled */ if(DevMsg.MsgNo) { if(DevMsg.MsgNo > 0) { Message( DevMsg.MsgNo ); } else { /* print the driver's message */ Print("%ls", (LPTR)DevMsg.szMsg); } } return; } bKeepDLL = (DevInfo.device_caps & 0x20); devreq = DevInfo.device_caps; /* doing a put cache to an external device */ if(!(devreq & 0x80)) { /* fill up the device info data structure */ DevInfo.npix = FrameXSize( lpFrame ); DevInfo.nlin = FrameYSize( lpFrame ); DevInfo.bpl = FrameXSize( lpFrame ); DevInfo.xres = DevInfo.yres = FrameResolution( lpFrame ); DevInfo.bpp = 8; } else { DevInfo.port = port; /* set the port for devices which require it */ #ifndef WIN32 DevInfo.vgaaddr = GetA000H(); /* set the VGA buffer address */ #endif } /* see if we need to take over display */ if(devreq & 1) { /* Hide the Cursor */ ShowCursor( FALSE ); /* Create the acquire window: it doesn't have the visable bit set */ AstralDlg( YES, hInstance, hWindow, IDD_GRAB, AcquireProc); AstralDlgShow( IDD_GRAB ); /* Enter the picture window command processor */ SetCapture( AstralDlgGet( IDD_GRAB ) ); /* set the data structures */ DevInfo.hInst = hInstance; DevInfo.hPw = AstralDlgGet( IDD_GRAB ); /* call display driver disable */ #ifndef WIN32 PicwinOn((LPSTR)palette1); #endif } if(devreq & 0x40) { // devstart does everything DevInfo.FpPtr = (LPTRPROC)MakeProcInstance( (FARPROC)grabber_frame_ptr, DevInfo.hInst); DevInfo.FoPtr = (LPTRPROC)MakeProcInstance( (FARPROC)grabber_frame_open, DevInfo.hInst); DevInfo.FsPtr = (LPTRPROC)MakeProcInstance( (FARPROC)grabber_frame_set, DevInfo.hInst); DevInfo.FcPtr = (LPROC)MakeProcInstance( (FARPROC)grabber_frame_close, DevInfo.hInst); DevInfo.CcPtr = (LPROC)MakeProcInstance( (FARPROC)grabber_AstralClockCursor, DevInfo.hInst); } DevInfo.bLineArtAsGray = Control.LineArtAsGray; if(!DevCall(DEV_START, (LPTR)&DevInfo)) { /* if get, fill struct */ back_to_windows(devreq & 1); /* restore if true */ DevCall(DEV_MSG, (LPTR)&DevMsg); /* if MsgNo == 0, then user cancelled */ if(DevMsg.MsgNo) { if(DevMsg.MsgNo > 0) { Message( DevMsg.MsgNo ); } else { /* print the driver's message */ Print("%ls", (LPTR)DevMsg.szMsg); } } if(devreq & 0x40) { // devstart does everything FreeProcInstance((FARPROC)DevInfo.FpPtr); FreeProcInstance((FARPROC)DevInfo.FoPtr); FreeProcInstance((FARPROC)DevInfo.FsPtr); FreeProcInstance((FARPROC)DevInfo.FcPtr); FreeProcInstance((FARPROC)DevInfo.CcPtr); } DevClose(); /* close the device */ return; } /* DEV_START returned ok, now get or put image data if not done */ if((devreq & 0xc0) == 0x80) { // putting data into the cache with devreads if(((devreq & 4) == 4) || ((devreq & 0x0c) == 0)) { depth = 1; } else { if((devreq & 8) == 8) { depth = 2; } else { if((devreq & 0x0c) == 0x0c) { depth = 3; } } } lpOldFrame = frame_set( NULL ); if(!(lpFrame = FrameOpen( (FRMDATATYPE)depth,DevInfo.npix,DevInfo.nlin,DevInfo.xres))) { back_to_windows(devreq & 1); /* Restore if true */ FrameError(IDS_EIMAGEOPEN); return; } frame_set(lpFrame); if(!(devreq & 2)) { for ( lncnt=0; lncnt<DevInfo.nlin; lncnt++ ) { DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, YES); if(!DevCall(DEV_READ, (LPTR)&DevData)) { back_to_windows(devreq & 1); /* Restore if true */ DevCall(DEV_MSG, (LPTR)&DevMsg); /* if MsgNo == 0, then user cancelled */ if(DevMsg.MsgNo) { Print("Unable to get data from device"); } else { DevInfo.nlin = lncnt; // hand scanner, get total lines } return; } } } else { /* special willow gs reader */ /* read even bytes, even lines */ for ( lncnt=0; lncnt<DevInfo.nlin; lncnt+=2 ) { DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, YES); if(!DevCall(DEV_READ0, (LPTR)&DevData)) { back_to_windows(devreq & 1); /* Restore if true */ Print("Unable to get data from device"); return; } } /* read odd bytes, even lines */ for ( lncnt=0; lncnt<DevInfo.nlin; lncnt+=2 ) { DevData.ImageAddress = FramePointer(lpFrame, 1, lncnt, YES); if(!DevCall(DEV_READ1, (LPTR)&DevData)) { back_to_windows(devreq & 1); /* Restore if true */ Print("Unable to get data from device"); return; } } /* read even bytes, odd lines */ for ( lncnt=1; lncnt<DevInfo.nlin; lncnt+=2 ) { DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, YES); if(!DevCall(DEV_READ2, (LPTR)&DevData)) { back_to_windows(devreq & 1); /* Restore if true */ Print("Unable to get data from device"); return; } } /* read odd bytes, odd lines */ for ( lncnt=1; lncnt<DevInfo.nlin; lncnt+=2 ) { DevData.ImageAddress = FramePointer(lpFrame, 1, lncnt, YES); if(!DevCall(DEV_READ3, (LPTR)&DevData)) { back_to_windows(devreq & 1); /* Restore if true */ Print("Unable to get data from device"); return; } } } FrameClose( lpOldFrame ); back_to_windows(devreq & 1); /* Restore if true */ if(DevInfo.bpp == 1) { Datatype = IDC_SAVELA; } else { if(DevInfo.bpp == 8) { Datatype = IDC_SAVECT; } else { Datatype = IDC_SAVE24BITCOLOR; } } /* Setup the new image and bring up the new image window */ LPIMAGE lpNewImage = CreateImage(NULL, lpFrame, NULL, NULL, Control.DefaultFileType, Datatype, IMG_DOCUMENT, NULL); if (lpNewImage) { if (PictPubApp.OpenDocumentFile((LPSTR)lpNewImage->CurFile, lpNewImage)) { /* only version of image is in the cache */ /* so insure user is asked about saving when done */ lpNewImage->fChanged = TRUE; } else DestroyImage(lpNewImage); } DevClose(); /* close the device */ } else { LPIMAGE lpNewImage = NULL; /* enable the frame created by DevStart */ lpFrame = frame_set(NULL); /* putting data to external device with DevWrites */ if((devreq & 0xc0) == 0) { for ( lncnt=0; lncnt<DevInfo.nlin; lncnt++ ) { AstralClockCursor( lncnt, DevInfo.nlin, NO ); DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, NO); if(!DevCall(DEV_WRITE, (LPTR)&DevData)) { Print("Unable to put data to device"); return; } } } else { /* devstart has created a frame with image data */ FreeProcInstance((FARPROC)DevInfo.FpPtr); FreeProcInstance((FARPROC)DevInfo.FoPtr); FreeProcInstance((FARPROC)DevInfo.FsPtr); FreeProcInstance((FARPROC)DevInfo.FcPtr); if(DevInfo.bpp == 1) { Datatype = IDC_SAVELA; } else { if(DevInfo.bpp == 8) { Datatype = IDC_SAVECT; } else { Datatype = IDC_SAVE24BITCOLOR; } } back_to_windows(devreq & 1); /* Restore if true */ /* enable the frame created by DevStart */ lpFrame = frame_set(NULL); /* DevInfo.nlin returns the actual line count */ if(FrameYSize(lpFrame) <= DevInfo.nlin) { /* Setup the new image and bring up the new image window */ { lpNewImage = CreateImage(NULL, lpFrame, NULL, NULL, Control.DefaultFileType, Datatype, IMG_DOCUMENT, NULL); if (lpNewImage) { if (!PictPubApp.OpenDocumentFile((LPSTR)lpNewImage->CurFile, lpNewImage)) { DestroyImage(lpNewImage); lpNewImage = NULL; } } } } else { /* create a new frame of the right size and copy */ /* the right number of lines to it */ lpOldFrame = FrameOpen( FrameType(lpFrame), FrameXSize(lpFrame), DevInfo.nlin, FrameResolution(lpFrame)); AstralCursor( IDC_WAIT ); for(lncnt=0; lncnt<DevInfo.nlin; lncnt++) { FrameCopyLine(lpFrame, lpOldFrame, lncnt); } FrameClose(lpFrame); lpFrame = lpOldFrame; AstralCursor( NULL ); /* Setup the new image and bring up the new image window */ lpNewImage = CreateImage(NULL, lpFrame, NULL, NULL, Control.DefaultFileType, Datatype, IMG_DOCUMENT, NULL); if (lpNewImage) { if (!PictPubApp.OpenDocumentFile((LPSTR)lpNewImage->CurFile, lpNewImage)) { DestroyImage(lpNewImage); lpNewImage = NULL; } } } /* only version of image is in the cache */ /* so insure user is asked about saving when done */ if (lpNewImage) lpNewImage->fChanged = TRUE; DevClose(); /* close the device */ } } }
static LPTR FrameToPaletteDIB( LPFRAME lpFrame, LPRECT lpRect ) { int y, bpl, i; LPTR lpSrc, lpDIBMem; HPTR lpDstLine; HPTR lpDst; DWORD lCount, lImageSize, lInfoSize; int iCount, dx, dy; LPBITMAPINFO lpInfo; if ( !lpFrame ) return( NULL ); dx = (lpRect->right - lpRect->left) + 1; dy = (lpRect->bottom - lpRect->top) + 1; bpl = dx; lInfoSize = sizeof(BITMAPINFOHEADER) + 256*sizeof(RGBQUAD); bpl = 4 * ((bpl + 3)/4); // DIB packing lImageSize = (long)bpl * dy; lCount = lInfoSize + lImageSize; // Allocate the memory to hold the DIB if ( !(lpDIBMem = Alloc( lCount )) ) { FrameSetError( ERR_MALLOC ); return( NULL ); } lpInfo = (LPBITMAPINFO)lpDIBMem; lpInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); lpInfo->bmiHeader.biWidth = dx; lpInfo->bmiHeader.biHeight = dy; lpInfo->bmiHeader.biPlanes = 1; lpInfo->bmiHeader.biCompression = BI_RGB; lpInfo->bmiHeader.biBitCount = 8; lpInfo->bmiHeader.biSizeImage = lImageSize; lpInfo->bmiHeader.biXPelsPerMeter = (10000L * (long) FrameResolution(lpFrame)) / 254L; lpInfo->bmiHeader.biYPelsPerMeter = (10000L * (long) FrameResolution(lpFrame)) / 254L; lpInfo->bmiHeader.biClrUsed = 256; lpInfo->bmiHeader.biClrImportant = 256; if (FrameType(lpFrame) == FDT_GRAYSCALE) { for (i = 0; i < 256; ++i) { lpInfo->bmiColors[i].rgbBlue = i; lpInfo->bmiColors[i].rgbGreen = i; lpInfo->bmiColors[i].rgbRed = i; lpInfo->bmiColors[i].rgbReserved = 0; } } else { LPCOLORMAP lpColorMap; lpColorMap = FrameGetColorMap( lpFrame ); if (!lpColorMap) { for (i = 0; i < 256; ++i) { lpInfo->bmiColors[i].rgbBlue = i; lpInfo->bmiColors[i].rgbGreen = i; lpInfo->bmiColors[i].rgbRed = i; lpInfo->bmiColors[i].rgbReserved = 0; } } else { for (i = 0; i < 256; ++i) { lpInfo->bmiColors[i].rgbBlue = lpColorMap->RGBData[i].blue; lpInfo->bmiColors[i].rgbGreen = lpColorMap->RGBData[i].green; lpInfo->bmiColors[i].rgbRed = lpColorMap->RGBData[i].red; lpInfo->bmiColors[i].rgbReserved = 0; } } } lpDstLine = (HPTR)lpDIBMem; lpDstLine += lInfoSize; // This goes backwards... for (y = lpRect->bottom; y >= lpRect->top; y--) { lpDst = lpDstLine; lpSrc = FramePointer(lpFrame, lpRect->left, y, NO); if (lpSrc) { iCount = dx; while (iCount-- > 0) *lpDst++ = *lpSrc++; } lpDstLine += bpl; } return( lpDIBMem ); }
// Message определяет пришедшее сообщение. Thread - поток. VOID Painter_PainterMessageProcessing( PQMSG Message, HAB Thread ) { // Устанавливаем приоритет потока. if( Message->msg == SM_PRIORITY ) { // Устанавливаем приоритет. LONG Class = (LONG) Message->mp1; LONG Delta = (LONG) Message->mp2; DosSetPriority( PRTYS_THREAD, Class, Delta, 0 ); // Запоминаем приоритет. Enhancer.Modules.Painter->Priority = MAKELONG( Class, Delta ); } // Перерисовываем рамки окон. if( Message->msg == SM_DRAW_FRAME ) { // Если рисование отключено - возврат. if( !Painter.Settings.Draw_frames ) return; // Кеш второго уровня: объединяем несколько заданий в одно. { // Ставим задание в список. Painter.RTSettings.Demand[ 0 ].Frame_window = (HWND) Message->mp1; Painter.RTSettings.Demand[ 0 ].Target = (ULONG) Message->mp2; // Забираем следующие задания из очереди и ставим их в список. INT Demand_total = 1; for( INT Count = 1; Count < PAINTER_DEMAND_TABLE; Count ++ ) { QMSG Next_message = {0}; WinPeekMsg( Thread, &Next_message, NULLHANDLE, SM_DRAW_FRAME, SM_DRAW_FRAME, PM_REMOVE ); if( Next_message.msg ) { Painter.RTSettings.Demand[ Count ].Frame_window = (HWND) Next_message.mp1; Painter.RTSettings.Demand[ Count ].Target = (ULONG) Next_message.mp2; Demand_total ++; } else { break; } } // Просматриваем составленный список и выполняем рисование. for( Count = 0; Count < Demand_total; Count ++ ) { // Узнаем окно рамки. HWND Frame_window = Painter.RTSettings.Demand[ Count ].Frame_window; // Если в списке нет значения - продолжаем перебор. if( Frame_window == NULLHANDLE ) continue; // Узнаем, какое окно надо перерисовать. ULONG Target = Painter.RTSettings.Demand[ Count ].Target; // Пробегаем список до конца и забираем задания для того же окна. if( Demand_total > 1 ) if( Count != Demand_total - 1 ) { for( INT Position = Count + 1; Position < Demand_total; Position ++ ) if( Painter.RTSettings.Demand[ Position ].Frame_window == Frame_window ) { Target = Target | Painter.RTSettings.Demand[ Position ].Target; Painter.RTSettings.Demand[ Position ].Frame_window = NULLHANDLE; } } // Если окна нет - продолжаем перебор. if( !WinIsWindow( WinQueryAnchorBlock( Frame_window ), Frame_window ) ) continue; // Перерисовываем рамку, применяя "общее задание". Painter_DrawWindowFrame( Frame_window, Target ); } } } // Перерисовываем картинку в левом верхнем углу окна. if( Message->msg == SM_DRAW_SYSMENU ) { // Если рисование отключено - возврат. if( !Painter.Settings.Draw_frames ) return; // Узнаем окно картинки. HWND SysMenu_window = (HWND) Message->mp1; // Если окна нет - возврат. if( !WinIsWindow( WinQueryAnchorBlock( SysMenu_window ), SysMenu_window ) ) return; // Узнаем, нажата ли картинка. LONG SysMenu_is_pressed = (LONG) Message->mp2; // Находим в списке значок окна. HPOINTER Icon = NULLHANDLE; HWND Frame_window = WinQueryWindow( SysMenu_window, QW_PARENT ); FindProperty( Frame_window, PRP_ICON, &Icon ); // Узнаем размер и расположение окна рамки. RECT Frame_rectangle = {0}; SWP Frame_placement = {0}; Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); // Если значок не найден - закрашиваем окно картинки. if( Icon == NULLHANDLE ) Painter_PreDrawControl( SysMenu_window, SYSCLR_BUTTONMIDDLE, 0, Frame_window, &Frame_rectangle, &Frame_placement ); // Иначе - рисуем картинку. else Painter_DrawSystemMenu( SysMenu_window, Frame_window, &Frame_rectangle, &Frame_placement, Icon, FT_UNKNOWN, SysMenu_is_pressed ); } // Перерисовываем кнопки. if( Message->msg == SM_DRAW_BUTTONS ) { // Если рисование отключено - возврат. if( !Painter.Settings.Draw_frames ) return; // Узнаем окно рамки. HWND Frame_window = (HWND) Message->mp1; // Если окна рамки нет - возврат. if( !WinIsWindow( WinQueryAnchorBlock( Frame_window ), Frame_window ) ) return; // Узнаем, как выглядит рамка окна. LONG Frame_type = FrameType( Frame_window ); // Узнаем окно заголовка. HWND TitleBar_window = WinWindowFromID( Frame_window, FID_TITLEBAR ); // Узнаем размер и расположение окна рамки. RECT Frame_rectangle = {0}; SWP Frame_placement = {0}; Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); // Рисуем кнопки. Painter_DrawButtons( Frame_window, Frame_type, &Frame_rectangle, &Frame_placement, TitleBar_window ); } // Задаем подходящее расположение для окна картинки и кнопок. if( Message->msg == SM_PREPARE_CONTROLS ) { // Узнаем окно рамки. HWND Frame_window = (HWND) Message->mp1; // Если окна рамки нет - возврат. if( !WinIsWindow( WinQueryAnchorBlock( Frame_window ), Frame_window ) ) return; // Узнаем размер и расположение окна. RECT Frame_rectangle = {0}; SWP Frame_placement = {0}; Painter_QueryFrameRectangeAndPlacement( Frame_window, &Frame_rectangle, &Frame_placement ); // Задаем правильное расположение окна картинки, заголовка и других окон. // При этом окно рамки получит одно сообщение WM_PAINT вместо нескольких. Painter_PrepareWindowControls( Frame_window, FT_UNKNOWN, &Frame_rectangle, &Frame_placement, NULLHANDLE, NULLHANDLE, NULLHANDLE ); } // Обновляем окно. if( Message->msg == SM_UPDATE_FRAME ) UpdateWindow( (HWND) Message->mp1 ); // Обновляем все окна. if( Message->msg == SM_UPDATE_ALL_FRAMES ) { // Перерисовываем рамки всех окон. UpdateAllWindows( QueryDesktopWindow() ); } // Возврат. return; }
void ImgInitDisplay(LPIMAGE lpImage, BOOL fGeneratePaletteLUT) /***********************************************************************/ { LPTR lpPaletteLUT; RGBS RGBmap[256]; LPRGB lpRGBmap; int nColors; FRMTYPEINFO TypeInfo, DstTypeInfo = ColorManager.Monitor.dst; LPOBJECT lpObject; lpObject = lpImage->GetDisplayObject(); if (!lpObject) return; FrameGetTypeInfo(ObjGetEditFrame(lpObject), &TypeInfo); if ( lpBltScreen->BitMapInfo.bmiHeader.biBitCount == 8 && !lpImage->lpPaletteLUT) { ProgressBegin(1, PROGRESS_ID(IDS_UNDOSETUPDISPLAY)); if (TypeInfo.DataType == FDT_PALETTECOLOR) lpPaletteLUT = Alloc(32768L); else lpPaletteLUT = NULL; if (lpPaletteLUT) { if (TypeInfo.ColorMap->NumEntries > MAX8BITCOLORS) { nColors = MAX8BITCOLORS; lpRGBmap = RGBmap; if (!ReducePalette(TypeInfo.ColorMap->RGBData, TypeInfo.ColorMap->NumEntries, lpRGBmap, nColors)) { FreeUp(lpPaletteLUT); lpPaletteLUT = NULL; } } else { lpRGBmap = TypeInfo.ColorMap->RGBData; nColors = TypeInfo.ColorMap->NumEntries; } } if (lpPaletteLUT) { if (fGeneratePaletteLUT) CreatePaletteLut15(lpRGBmap, nColors, lpPaletteLUT, AstralClockCursor); lpImage->lpPaletteLUT = lpPaletteLUT; lpImage->PaletteType = PT_CUSTOMPALETTE; lpImage->hPal = CreateLogicalPalette(lpRGBmap, nColors); GetObject(lpImage->hPal, sizeof(nColors), (void *)&nColors); lpImage->nPaletteEntries = GetPaletteEntries(lpImage->hPal, 0, nColors, lpImage->Palette); } else { if ( FrameType(ImgGetBaseEditFrame(lpImage)) <= FDT_GRAYSCALE) { lpImage->hPal = lpBltScreen->hGrayPal; lpImage->nPaletteEntries = lpBltScreen->nGrayEntries; lpImage->PaletteType = lpBltScreen->GrayPaletteType; lpImage->lpPaletteLUT = lpBltScreen->lpGrayPaletteLUT; copy((LPTR)lpBltScreen->GrayPalette, (LPTR)lpImage->Palette, sizeof(lpImage->Palette)); } else { lpImage->hPal = lpBltScreen->hColorPal; lpImage->nPaletteEntries = lpBltScreen->nColorEntries; lpImage->PaletteType = lpBltScreen->ColorPaletteType; lpImage->lpPaletteLUT = lpBltScreen->lpColorPaletteLUT; copy((LPTR)lpBltScreen->ColorPalette, (LPTR)lpImage->Palette, sizeof(lpImage->Palette)); } } ProgressEnd(); } if (lpImage->m_cmsXform) { if( Control.CMSEnabled && lpKCMSFreeProc ) { if (lpImage->PtInfo.toRCS != TypeInfo.ptInfo.toRCS && lpImage->PtInfo.frRCS != TypeInfo.ptInfo.frRCS ) { ( lpKCMSFreeProc )( lpImage->m_cmsXform ); lpImage->m_cmsXform = NULL; } } else lpImage->m_cmsXform = NULL; } if( Control.CMSEnabled && IsSrcPTSelected( &TypeInfo.ptInfo ) && IsDstPTSelected( &DstTypeInfo.ptInfo ) && lpKCMSCnctProc ) { lpImage->m_bDoCmsGamma = YES; if (!lpImage->m_cmsXform) { if( ( !FrameTypeInfoEqual( TypeInfo, DstTypeInfo ) ) && ConvertCRCtoUID( &TypeInfo, &DstTypeInfo ) ) { // save for later check to avoid a monitor reconnect. lpImage->PtInfo = TypeInfo.ptInfo; lpImage->m_cmsXform = ( *lpKCMSCnctProc )( &TypeInfo, &DstTypeInfo ); } else lpImage->m_cmsXform = NULL; } } else lpImage->m_cmsXform = NULL; }
/************************************************************ SaveWallpaper Saves the current picture into the specified file. Installs it as the system wallpaper (uses name given). Sets the INI tiled flag to the passed value returns FALSE if it could not save wallpaper. ************************************************************/ BOOL SaveWallpaper( LPSTR lpName, BOOL fTiled ) { WORD idDataType; STRING szSaveAs; LPFRAME lpFrame; int nBits, nPlanes, nDepth, nOutWidth, nOutHeight; if ( !lpImage ) return(FALSE); if ( !(lpFrame = ImgGetBaseEditFrame(lpImage)) ) return(FALSE); AstralCursor( IDC_WAIT ); /* Put up the wait cursor */ nBits = GetDeviceCaps( Window.hDC, BITSPIXEL ); nPlanes = GetDeviceCaps( Window.hDC, PLANES ); nDepth = nBits * nPlanes; nOutWidth = GetDeviceCaps( Window.hDC,HORZRES); nOutHeight = GetDeviceCaps( Window.hDC,VERTRES); // decide on proper depth if ( FrameType(lpFrame) == FDT_LINEART ) idDataType = IDC_SAVELA; else if (nDepth <= 4) { if( FrameType(lpFrame) == FDT_GRAYSCALE ) idDataType = IDC_SAVESP; else idDataType = IDC_SAVE4BITCOLOR; } else if( nDepth <= 8 || !Control.Save24BitWallpaper) { if ( FrameType(lpFrame) == FDT_GRAYSCALE ) idDataType = IDC_SAVECT; else idDataType = IDC_SAVE8BITCOLOR; } else { if ( FrameType(lpFrame) == FDT_GRAYSCALE ) idDataType = IDC_SAVECT; else idDataType = IDC_SAVE24BITCOLOR; } // Save file into the Windows directory GetWindowsDirectory(szSaveAs, sizeof(FNAME)); FixPath( szSaveAs ); lstrcat( szSaveAs, filename(lpName) ); stripext( szSaveAs ); lstrcat( szSaveAs, ".BMP" ); if ( !AstralImageSave( IDN_BMP, idDataType, szSaveAs ) ) goto ErrorExit; // Make szSaveAs the current wallpaper and apply WriteProfileString( "Desktop", "TileWallPaper", (fTiled?"1":"0") ); SystemParametersInfo( SPI_SETDESKWALLPAPER, 0, filename(szSaveAs), SPIF_UPDATEINIFILE ); AstralCursor( NULL ); /* Revert back to the old cursor */ return (TRUE); ErrorExit: AstralCursor( NULL ); /* Revert back to the old cursor */ return(FALSE); }
BOOL CombineObjObjects( LPIMAGE lpImage, LPCMD_PARMS lpCmdParms ) /************************************************************************/ { RECT rCombine,r; LPOBJECT lpBase, lpObj; LPALPHA lpAlpha, lpMask; LPFRAME lpDFrame, lpSFrame; LPTR lpDF, lpDM, *lpSM, *lpSF; int x, y, yy, depth; int N, H, W, i; double *lpAlphaTable, *AiXOi; double red,blue,green,k; POINT pt; double Oi, Ai, Mi, Mc; LPOBJECT *lpObject; FRMTYPEINFO TypeInfo; BOOL fCanDoOpacity; FRMDATATYPE MaskType = FDT_GRAYSCALE; if (!(lpImage)) return( FALSE ); ImgGetTypeInfo(lpImage, &TypeInfo); if (TypeInfo.DataType == FDT_LINEART && Mask.OneBitMask) MaskType = FDT_LINEART; fCanDoOpacity = CANDOTRANSPARENCY(TypeInfo.DataType); lpObj = lpBase = ImgGetBase(lpImage); if (!(depth = FrameDepth(ObjGetEditFrame(lpBase)))) depth = 1; // never worry about lineart N = ImgCountSelObjects(lpImage, NULL); ImgGetSelObjectRect(lpImage, &rCombine, YES); H = RectHeight(&rCombine); W = RectWidth (&rCombine); lpObject = NULL; AiXOi = lpAlphaTable = NULL; lpAlphaTable = (double *)Alloc((N+1) * sizeof(double)); AiXOi = (double *)Alloc(N * sizeof(double)); lpSM = (LPTR *)Alloc(N * sizeof(LPTR)); lpSF = (LPTR *)Alloc(N * sizeof(LPTR)); lpObject = (LPOBJECT *)Alloc(N * sizeof(LPOBJECT)); lpAlpha = MaskCreate(NULL, W, H, YES, Control.NoUndo, MaskType); lpDFrame = ImgGetBaseEditFrame(lpImage); lpDFrame = FrameOpen(FrameType(lpDFrame), W, H, FrameResolution(lpDFrame)); if (!lpAlphaTable || !lpObject || !AiXOi || !lpAlpha || !lpDFrame || !lpSM || !lpSF) { if (lpAlphaTable) FreeUp(lpAlphaTable); if (lpObject) FreeUp(lpObject); if (AiXOi) FreeUp(AiXOi); if (lpDFrame) FreeUp(lpDFrame); if (lpSF) FreeUp(lpSF); if (lpSM) FreeUp(lpSM); Message(IDS_EMEMALLOC); return(FALSE); } for (i=0; i < N; i++) lpObj = lpObject[i] = ImgGetSelObject(lpImage, lpObj); ImgEditInit(lpImage, ET_OBJECT, UT_DELETEOBJECTS, lpBase); ProgressBegin(1, PROGRESS_ID(IDS_UNDOOBJCOMBOBJS)); for (y = 0; y <= H; y++) { AstralClockCursor(y, H, NO); lpDF = FramePointer(lpDFrame, 0, y, YES); lpDM = PixmapPtr(&lpAlpha->Pixmap, PMT_EDIT, 0, y, YES); pt.y = y + rCombine.top; for (i=0; i < N; i++) { yy = pt.y - lpObject[i]->rObject.top; lpSFrame = ObjGetEditFrame(lpObject[i]); lpSF[i] = FramePointer(lpSFrame, 0, yy, NO); lpMask = ObjGetAlpha(lpObject[i]); lpSM[i] = PixmapPtr(&lpMask->Pixmap, PMT_EDIT, 0, yy, NO); } for (x = 0; x < W; x++) { lpAlphaTable[N] = 1.0; pt.x = x + rCombine.left; for (i=N-1; i >= 0; i--) { r = lpObject[i]->rObject; r.bottom++; r.right++; if (PtInRect(&r, pt)) { if (fCanDoOpacity) Oi = lpObject[i]->Opacity / 255.0; else Oi = 1; if (fCanDoOpacity) Ai = *lpSM[i]++ / 255.0; else if (*lpSM[i] < 128) { Ai = 0; lpSM[i]++; } else { Ai = 1; lpSM[i]++; } AiXOi[i] = Oi * Ai; lpAlphaTable[i] = lpAlphaTable[i+1] * (1.0 - AiXOi[i]); } else { AiXOi[i] = 1.0; lpAlphaTable[i] = lpAlphaTable[i+1]; } } Mc = 1.0 - lpAlphaTable[0]; lpDM[x] = (BYTE)(Mc * 255); red = blue = green = k = 0; for (i=0; i < N; i++) { r = lpObject[i]->rObject; r.bottom++; r.right++; if (PtInRect(&r, pt)) { Mi = AiXOi[i] * lpAlphaTable[i+1]; switch(depth) { case 1: red += *lpSF[i]++ * Mi; break; case 3: red += *lpSF[i]++ * Mi; green += *lpSF[i]++ * Mi; blue += *lpSF[i]++ * Mi; break; case 4: red += *lpSF[i]++ * Mi; green += *lpSF[i]++ * Mi; blue += *lpSF[i]++ * Mi; k += *lpSF[i]++ * Mi; break; } } } if (Mc == 0.0) Mc = 1.0; switch(depth) { case 1: *lpDF++ = (BYTE)(red / Mc); break; case 3: *lpDF++ = (BYTE)(red / Mc); *lpDF++ = (BYTE)(green / Mc); *lpDF++ = (BYTE)(blue / Mc); break; case 4: *lpDF++ = (BYTE)(red / Mc); *lpDF++ = (BYTE)(green / Mc); *lpDF++ = (BYTE)(blue / Mc); *lpDF++ = (BYTE)(k / Mc); break; } } } lpObj = ObjCreateFromFrame(ST_PERMANENT, lpDFrame, lpAlpha, &rCombine, Control.NoUndo ); lpObj->fSelected = YES; lpObj->fUndoDeleted = YES; ImgAddNewObject(lpImage, lpObj); for (i=0; i < N; i++) lpObject[i]->fDeleted = YES; ImgEditedObject(lpImage, lpBase, IDS_UNDOOBJCOMBOBJS, NULL); UpdateImage(lpImage, &rCombine, YES); FreeUp(lpSM); FreeUp(lpSF); FreeUp(AiXOi); FreeUp(lpAlphaTable); FreeUp(lpObject); ProgressEnd(); return( TRUE ); }