Thank you Richard and Dave for reply and suggestion. Regards, Gopinath.
Gopi Nath
Posts
-
Application check for virus -
Application check for virusHello, We have an application. We want to check while starting that application in any system (customer place) whether any virus is there or not or the exe went out with or without virus. Can we do this in C++ in the application startup itself or can we use any third party software? Please suggest. Regards, Gopinath.
-
RGB image to CMYK gdi+Hello, I am trying to adjust the color balance (CYMK) of an image like this is in photoshop or some other applications. From examples, i tried changing the current RGB to CMYK (for each pixel) using the below code.
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
tmpbmp->GetPixel(i, j, &clr);R = clr.GetR(); G = clr.GetG(); B = clr.GetB(); c = \_cyanclr / 255.0; // \_cyanclr - user input in % m = \_magentaclr / 255.0; y = \_yellowclr / 255.0; k = \_blackclr / 255.0; rr = c \* (1.0 - k) + k; gg = m \* (1.0 - k) + k; bb = y \* (1.0 - k) + k; rr = (1.0 - rr) \* 255.0 + 0.5; gg = (1.0 - gg) \* 255.0 + 0.5; bb = (1.0 - bb) \* 255.0 + 0.5; // here i dont know how to adjust new RGB with old one R += rr; G += gg; B += bb; R = R < 0 ? 0 : (R > 255) ? 255 : R; G = G < 0 ? 0 : (G > 255) ? 255 : G; B = B < 0 ? 0 : (B > 255) ? 255 : B; output->SetPixel(i, j, Gdiplus::Color(R, G, B)); } }
With this code, i am not getting the same result like in photoshop and other applications. I am not sure whether I am doing in right method or not. Please suggest. I am using C++ and gdi+. Regards, Gopinath.
-
Zoom image on mouse positionThank you Richard, tried with GDI+ only with some changes, now, i am able to get the required output. Regards, Gopinath.
-
Zoom image on mouse positionHello, I am displaying an image in a static control (in a dialog) and trying to stretch according to the zoom factor on mouse position. Zoom on mouse position is working fine, but the image is not fitting inside the static control, going all over the dialog. Below is the code.
// source image
Gdiplus::Bitmap *gpBitmap = new Gdiplus::Bitmap(mImagePath);int origW = gpBitmap->GetWidth(); // 5298 - original width int origH = gpBitmap->GetHeight(); // 2728 - original height // destination rectangle RECT rcVPC; GetClientRect(hWnd, &rcVPC); // 501 X 255 - size of the static control HDC hDc = GetDC(hWnd); float perW = (float)rcVPC.right / (float)origW; float perH = (float)rcVPC.bottom / (float)origH; int newW = origW \* perW \* mVPZoomFactor; // starting factor is 1.0 and multiplying with 1.2 with each zoom int newH = origH \* perH \* mVPZoomFactor; Gdiplus::Bitmap \*bmpResized = new Gdiplus::Bitmap(newW, newH, gpBitmap->GetPixelFormat()); Gdiplus::Graphics \*graphics = new Gdiplus::Graphics(bmpResized); graphics->DrawImage(gpBitmap, 0, 0, newW, newH); int zoomWidth = (int)(0.5 + newW \* mVPZoomFactor); int zoomHeight = (int)(0.5 + newH \* mVPZoomFactor); //Find the position "factor" double dXFactor = (double)rcVPC.right / stX; // stX, stY - mouse position on zoom double dYFactor = (double)rcVPC.bottom / stY; //Find the origin int left = stX - zoomWidth / dXFactor; int right = stY - zoomHeight / dYFactor; HBRUSH hB = GetSysColorBrush(COLOR\_3DDKSHADOW); FillRect(hDc, &rcVPC, hB); HDC hdcMem = CreateCompatibleDC(hDc); bmpResized->GetHBITMAP(0, &hBmpVPCanvas); HBITMAP oldBmp = (HBITMAP)SelectObject(hdcMem, hBmpVPCanvas); //use StretchBlt StretchBlt(hDc, left, right, zoomWidth, zoomHeight, hdcMem, 0, 0, newW, newH, SRCCOPY); SelectObject(hdcMem, oldBmp); DeleteDC(hdcMem); delete gpBitmap;
Can anyone help me, what i am doing wrong? Regards, Gopinath.
-
Add Window procedure to picture controlThank you. Will give it a try.
-
Add Window procedure to picture controlThanks. my application is in win32 and picture control created through toolbox. how to subclass this control to CStatic (MFC) derived class?
-
Add Window procedure to picture controlThanks, will check on this.
-
Add Window procedure to picture controlHello, In a dialog, i have added picture control from resource. in this i am displaying an image accordingly at the runtime which is working fine. I need to zoom in / zoom out the displayed image according to mouse wheel move. I thought of adding window procedure to that picture control, so that i can handle mouse command over there. in MFC, i can see options and examples, but in win32 api, i dont know how to do that. Can anyone suggest me how to do. Regards, Gopi.
-
gdi+ bitmap save on existing file - showing errorThank you Richard. This helps me to solve my issue. Regards, Gopi.
-
gdi+ bitmap save on existing file - showing errorHello, I am trying to draw an image (2nd image) over the other image (existing image file - 1st image) using gdi+ bitmap and graphics and then saving (overwriting) the same 1st image file. But saving is not getting done, when i use GetLasError(), it shows error message, "The process cannot access the file because it is being used by another process" Here is the code what i am doing.
Gdiplus::Bitmap *gpBitmap = new Gdiplus::Bitmap(mImagePath1); /// existing image file
Gdiplus::Graphics *gr = Gdiplus::Graphics::FromImage(gpBitmap);Gdiplus::Bitmap img(mImagePath2); // second image
Gdiplus::Bitmap* pThumbnail = static_cast(img.GetThumbnailImage(32, 32, NULL, NULL));
gr->DrawImage(pThumbnail, newWpos, newHpos); // drawing the second image on some position of first imageGdiplus::Status stat = gpBitmap->Save(mImagePath1, pClsid); // pClsid - image encoder set for png output
I tried making copy also, but same issue. please suggest. Regards, Gopi.
-
Not able to set DPI for PNG files - libpngThat's the problem. they didn't provide source code nowhere.
-
Not able to set DPI for PNG files - libpngHello Everyone, I am using libpng library for generating PNG files which is working fine. But it always generating with DPI 96 by default. I tried using png_set_pHYs for setting the resolution before calling png_write_png. But its not generating with the specified DPI. Before and after calling png_set_pHYs, i am checking the DPI using png_get_pHYs, it was showing the correct values whatever i set. What may be the issue? And is that possible to set DPI for PNG file? Please suggest. Regards, Gopinath.
-
Select and Pick lines in OpenGLHi Leon, This code is working fine for 2D points. Is there anyway to get the logic for 3D points? Thanks in advance. Regards, Gopinath.
-
Select and Pick lines in OpenGLHi Leon, Sorry for late reply. Got time to work on this now only. Awesome. This one works fine as I expected. Thanks again. Regards, Gopinath.
-
TCPClient to multiple systemsHello Richard, There was an issue from my side. While sending the request (writetosender() function), I am not segregating the request according to the client. Now it is fixed and working fine. Thanks again. Regards, Gopinath.
-
TCPClient to multiple systemsHere is where I am using the ip address to send the request.
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ip_address), portNo);
client.Connect(serverEndPoint);Let me check in google also as you mentioned. Thanks again. Regards, Gopinath.
-
TCPClient to multiple systemsHello Richard, Thanks for your reply. First two session in earlier post is the code from sender. Here are the code for the functions mentioned in the thread.
public void readFromReceiver(object clients)
{
ASCIIEncoding encoder = new ASCIIEncoding();
TcpClient client = (TcpClient)clients;
NetworkStream clientStream = (client).GetStream();
byte[] msg_type = new byte[1]; // to read header
bool flag = false;
while(!flag)
{
try
{
// need to get back msg from receiver about status
int bytesRead = 0;
bytesRead = clientStream.Read(msg_type, 0, 1);
int msg = (int)(msg_type[0]);
string retVal = "";
if (msg == 3) // return success
{
retVal = receiveString(clientStream); // return message
}
}
catch(Exception ex)
{} }
}
public void writeToReceiver(object clients)
{
ASCIIEncoding encoder = new ASCIIEncoding();
TcpClient client = (TcpClient)clients;
NetworkStream clientStream = (client).GetStream();bool flag = false; while(!flag) { while (nQReceiveProjName.Count > 0) // list of request { try { string cmdToPass = fnGetXMLString(nQReceiveProjName\[0\]); nQReceiveProjName.RemoveAt(0); sendCommand(clientStream, 5); sendString(clientStream, cmdToPass); } catch(Exception ex) { } } }
}
In both the cases, client remote end point is holding the ip address of the client in which the first request is received. Regards, Gopinath.
-
TCPClient to multiple systemsHello Everybody, I am writing a sender and receiver application, sender in C#,WPF and receiver in C# WinForms. In sender, will be having a list of task to do, which will be sent to multiple receivers running in multiple systems. Here is the code in Sender
for (int j = 0; j < tmpfilled.Count; j++)
{
// some statements related to send to receiver
////////////
Thread thFromReceiver = new Thread(new ThreadStart(thFromReceiverFunction));
thFromReceiver.Start();
}//Body of the thFromReceiverFunction()
public void thFromReceiverFunction()
{
// here again two thread, for read and write
try
{
TcpClient client = new TcpClient();
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ip_address), portNo);
client.Connect(serverEndPoint);Thread readThreadRec = new Thread(new ParameterizedThreadStart(readFromReceiver)); Thread writeThreadRec = new Thread(new ParameterizedThreadStart(writeToReceiver)); readThreadRec.Start(client); writeThreadRec.Start(client); } catch(Exception ex) { }
In Receiver,
// inside a thread
TcpListener tcpListener = new TcpListener(IPAddress.Any, portNo); // same port number
tcpListener.Start();while (true) { //blocks until a client has connected to the server TcpClient client = tcpListener.AcceptTcpClient(); Thread readThread = new Thread(new ParameterizedThreadStart(read\_thread)); readThread.IsBackground = true; Thread writeThread = new Thread(new ParameterizedThreadStart(write\_thread)); writeThread.IsBackground = true; readThread.Start(client); writeThread.Start(client); readThread.Join(); writeThread.Join(); client.Close(); }
My problem is, if I am sending to single receiver, everything is working fine. If multiple receivers are running in multiple systems, then, ipaddress which I am sending the request, shows right, but whichever the client receives the first request, all other requests are going to the same client, even though I am sending to different ipaddress (through thFromReceiverFunction() funtion). I think I explained the issue properly, if not please let me know. Thanks in advance. Regards, Gopinath.
-
Change Tabs in Ribbon Control dynamically - C++I think, this will not work for my solution. Anyways, let me try.