WWW.ИСХОДНИКИ.РУ cpp.sources.ru
java.sources.ru web.sources.ru soft.sources.ru
jdbc.sources.ru asp.sources.ru api.sources.ru

  Форум на исходниках
  C / C++ / Visual C++
  Кто-нить юзал GDI+?

СПРОСИТЬ  ОТВЕТИТЬ
профайл | регистрация | faq

Автор Тема:   Кто-нить юзал GDI+?
ADK опубликован 12-02-2002 08:28 MSK   Click Here to See the Profile for ADK   Click Here to Email ADK  
Вот, поставил последний (наверное, уже предпоследний ;-)) Platform SDK, решил покомпилить кое-чего. Конкретно - GDI+. ВСё, каталоги прописал, даже Visual Assist настроил. Мля, при компиляции кода из MSDN GDI+ : Getting Starting выдаёт туеву хучу каких-то ошибок. Никто не сталкивался? вот сэмпл:

#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;

VOID OnPaint(HDC hdc)
{
Graphics graphics(hdc);
Pen pen(Color(255, 0, 0, 255));

graphics.DrawLine(&pen, 0, 0, 200, 100);
}


LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow)
{
HWND hWnd;
MSG msg;
WNDCLASS wndClass;
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;

// Initialize GDI+.
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;
wndClass.hInstance = hInstance;
wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = TEXT("GettingStarted");

RegisterClass(&wndClass);

hWnd = CreateWindow(
TEXT("GettingStarted"), // window class name
TEXT("Getting Started"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL); // creation parameters

ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);

while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

GdiplusShutdown(gdiplusToken);
return msg.wParam;
} // WinMain


LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;

switch(message)
{
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
OnPaint(hdc);
EndPaint(hWnd, &ps);
return 0;

case WM_DESTROY:
PostQuitMessage(0);
return 0;

default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
} // WndProc

DmitryRyvkin опубликован 12-02-2002 09:24 MSK     Click Here to See the Profile for DmitryRyvkin  Click Here to Email DmitryRyvkin     
Гдя взять сабж ? + те
Vovan опубликован 12-02-2002 13:06 MSK     Click Here to See the Profile for Vovan  Click Here to Email Vovan     
Да, где взять этот GDI+?
И сколько весит?
ADK опубликован 12-02-2002 13:39 MSK     Click Here to See the Profile for ADK  Click Here to Email ADK     
Всё, я откомпилировал....
Про сабж:

Это новая мощная графическая технология Microsoft, призванная заменить нынешний GDI. Куча новых возможностей, включая градиенты, прозрачность, поддержку и конвертацию в разные графические форматы, куча новых графических функций. Технически сабж представляет собой gdiplus.dll 1,62 Мб, после установки её в ОС становятся доступны функции gdi plus. Доступен для загрузки с узла MS. Для разработки программ требуется последний SDK, который тоже (теоретически) доступен для загрузки. Однако, я думаю, можно выбрать из этого SDK нужные файлы и поместить их на этом сайте для загрузки (purpe?).

Вот, к примеру, как в gdiplus преобразовать файл в формат png:

Converting a BMP Image to a PNG Image
To save an image to a disk file, call the Save method of the Image class. The following console application loads a BMP image from a disk file, converts the image to the PNG format, and saves the converted image to a new disk file. The main function relies on the helper function GetEncoderClsid, which is shown in Retrieving the Class Identifier for an Encoder.

#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;

INT GetEncoderClsid(const WCHAR* format, CLSID* pClsid); // helper function

INT main()
{
// Initialize GDI+.
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

CLSID encoderClsid;
Status stat;
Image* image = new Image(L"Bird.bmp");

// Get the CLSID of the PNG encoder.
GetEncoderClsid(L"image/png", &encoderClsid);

stat = image->Save(L"Bird.png", &encoderClsid, NULL);

if(stat == Ok)
printf("Bird.png was saved successfully\n");
else
printf("Failure: stat = %d\n", stat);

delete image;
GdiplusShutdown(gdiplusToken);
return 0;
}

Platform SDK Release: August 2001

Статья по сабжу есть на rsdn.ru

Vovan опубликован 13-02-2002 12:22 MSK     Click Here to See the Profile for Vovan  Click Here to Email Vovan     
Да purpe, давай выложи всё что скажет ADK сюда на сайт, что-бы с микрософта лишнее не качать!!!
ADK опубликован 13-02-2002 13:05 MSK     Click Here to See the Profile for ADK  Click Here to Email ADK     
kourov@newmail.ru, усли нужно
purpe опубликован 13-02-2002 13:20 MSK     Click Here to See the Profile for purpe  Click Here to Email purpe     
у хостинг провайдера место на диске ограничено и сайт уже занимает 95% выделенного пространства. Поэтому, я задумываюсь над каждыми 100 килобайтами. Ещё форум потихоньку отжирает оставшееся место.
Кстати, у этого сайта исходящий трафик составляет 18Гб в месяц :)
Drugan опубликован 13-02-2002 13:30 MSK     Click Here to See the Profile for Drugan  Click Here to Email Drugan     
В чем проблема? Я позавчера поставил Visual Studio.Net и не могу откомпилировать. К проекту надо библиотеку подключать? В чем проблема ?

;(onflict

ADK опубликован 13-02-2002 13:34 MSK     Click Here to See the Profile for ADK  Click Here to Email ADK     
purpe, давай все серьёзные даунлоады перемести на бесплатный хостинг типа h1.ru...

А HTML код форума не оптимален. Вот изречение Вована (не знаю, как HTML отобразится):

<TD>
<IMG SRC="/NonCGI/posticon.gif" BORDER=0>
<FONT SIZE="2" FACE="Verdana, Arial">
<FONT SIZE="1" color="" face="Verdana, Arial">опубликован 13-02-2002 12:22 MSK    
<A HREF="/cgi-bin/sources/ubbmisc.pl?action=getbio&UserName=Vovan" target=_new><IMG SRC="/NonCGI/profile.gif" WIDTH=22 HEIGHT=11 BORDER=0 ALT="Click Here to See the Profile for Vovan"></A>  <A HREF="/cgi-bin/sources/Ultimate.pl?action=email&ToWhom=Vovan" target=_new><IMG SRC="/NonCGI/email.gif" BORDER=0 WIDTH=24 HEIGHT=11 ALT="Click Here to Email Vovan"></A>     
</FONT><HR>Да purpe, давай выложи всё что скажет ADK сюда на сайт, что-бы с микрософта лишнее не качать!!!</FONT></td>

Много, да?

ADK опубликован 13-02-2002 13:37 MSK     Click Here to See the Profile for ADK  Click Here to Email ADK     
Вообще-то этот пример как раз более-менее, но общее ощущуние всё равно не очень. Лучше бы побольше юзал CSS.
SUnteXx опубликован 14-02-2002 02:22 MSK     Click Here to See the Profile for SUnteXx  Click Here to Email SUnteXx     
2purpe:
ADK прав ЦСС рулезз! Столько места сэкономишь!
У меня к тебе вопрос! Тебе банеры много лавэ приносят! Просто редко встречаются. Какой у тя трафик в день? Хотя бы приблизительно! Просто медленноват сайт, а посящение бешенное (как мне кажется!) Вечно кто-нить где-нить да сидит!))
Может разовьешь как-нить сервак. Больше может места даст пров? Сайт то не просто так валяется без посящений, ... Банеров натыкай, ...
Плюс помню кто-то обещал в ФЕВРАЛЕ движок сайта поменять! Случайно не помнишь кто?

2ADK:
про бесплатное место для паг и файла - мысль хорошая, но вот качка будет никакая! И так на IDSN'е хреново качается, а так бедет вообще сакс. Пытался с твоего сайта скачать кряк для Visual Assist, долго гимороился, очень долго, хотя файл менее 100 кило! Так что вот какие они беспл. паги:(

Vovan опубликован 14-02-2002 13:28 MSK     Click Here to See the Profile for Vovan  Click Here to Email Vovan     
To ADK: Что ты сделал что-бы твой код всёже заработал? А то никак, я уж и Gdiplus.lib подключал, всё равно не компилиться!
ADK опубликован 14-02-2002 13:41 MSK     Click Here to See the Profile for ADK  Click Here to Email ADK     
А что пишет-то? Сейчас я тебе свой тестовый проект замылю.
ADK опубликован 14-02-2002 13:45 MSK     Click Here to See the Profile for ADK  Click Here to Email ADK     
Vovan, ты запаришься мыло прокачивать. Я тебе ещё GDI+ Runtime выслал 1,5 Мб!
Vovan опубликован 15-02-2002 10:40 MSK     Click Here to See the Profile for Vovan  Click Here to Email Vovan     
Тебе ADK конечно спасибо, но эта библиотека "gdiplus.dll" есть в WinXP, точно такая же и версия тоже такая.
И у меня всё и так заработало, дело было не в этом.
GDI+ конечно круто, но прозрачность, рисуеться очень медленно, буквально на глазах :(
Мой комп: AMD 266, 160Mb RAM, Video: 2Mb и WinXP
ADK опубликован 15-02-2002 11:01 MSK     Click Here to See the Profile for ADK  Click Here to Email ADK     
Наверное, ты битмэп здоровенный юзал! Но то, что она тормозит, это да.
Vovan опубликован 15-02-2002 13:10 MSK     Click Here to See the Profile for Vovan  Click Here to Email Vovan     
Да какой битмап!
Я только FillRectangle и то не очень большой,
вот без прозрачности всё вроде нормально.

ADK: Ты не знаешь как можно используя это всё сделать прозрачное окно, а то что-то не получаеться, да и документации нет.

Ещё вопрос:
Как прога будет работать допустим под Win98, если там нет "gdiplus.dll". Что нужно поставлять её вместе с прогой, а она ведь ~1.5 Mb?

ADK опубликован 15-02-2002 13:37 MSK     Click Here to See the Profile for ADK  Click Here to Email ADK     
Её и поставляь. Позрачное окно только на 2К/XP

The core functionality is done in only 4 lines of code (6 if you include variable definitions). The rest is just wizard-generated MFC code.

HWND hWnd;
POINT pt;
::GetCursorPos(&pt);
hWnd=::WindowFromPoint(pt);
SetWindowLong(hWnd,GWL_EXSTYLE,GetWindowLong(hWnd,GWL_EXSTYLE)^WS_EX_LAYERED);
SetLayeredWindowAttributes(hWnd,RGB(0,0,0),m_slider.GetPos(),LWA_ALPHA);

First it finds the window under the current cursor position by using GetCursorPos() and WindowFromPoint, then it toggles its WS_EX_LAYERED (new in W2k) style using SetWindowLong, and finally, it sets its transparency to a value (between 0 and 255) defined by a slider control. The new SetLayeredWindowAttributes function is available only on Windows 2000, and is well-documented in the current MSDN library. You can also use it for color-keying, i.e. to make pixels of a specific color completely transparent, while leaving other pixels unchanged. The two effects can also be combined.

SetLayeredWindowAttributes is defined as follows:

BOOL SetLayeredWindowAttributes(
HWND hwnd, // handle to the layered window
COLORREF crKey, // specifies the color key
BYTE bAlpha, // value for the blend function
DWORD dwFlags // action
);

SetLayeredWindowAttributes can also be used to fade in/out other windows, or to create irregularly formed windows (this was also possible using window regions, but that was much slower).

I personally use this program to make my Taskbar, ICQ and Winamp windows transparent, since these are always on top, and I prefer being able to see what happens behind them.

Have Fun!

СПРОСИТЬ  ОТВЕТИТЬ
Перейти:


E-mail | WWW.ИСХОДНИКИ.RU

Powered by: Ultimate Bulletin Board, Freeware Version 5.10a
Purchase our Licensed Version- which adds many more features!
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.